Control BT Arduino-Android dont work with usb conect


hi friends afternoon, writing see if can me little problem have , brings me head truth. have bluetooth shield seeedstudio , mobile android  establish one-way communication control relay board.

the tick of matter when have arduino connected pc via usb works perfectly, when have connected battery ... connects , other characters happened, na ... want xd attached code if can see escapes me. greetings , in advance.

the code followin:

quote


#include <softwareserial.h>   //software serial port

#define rxd         7 
#define txd         6

#define pinledon      12
#define pinledoff      13
#define pinbuzz        0

#define ledon()     {digitalwrite(pinledon, high);digitalwrite(pinledoff, low);}
#define ledoff()    {digitalwrite(pinledoff, high);digitalwrite(pinledon, low);}
#define allled()    {digitalwrite(pinledon, low);digitalwrite(pinledoff, low);}
#define buzz()     {analogwrite(pinbuzz, 255);delay(1000);analogwrite(pinbuzz, 0);}
#define repeatledon()     {digitalwrite(pinledoff, low);digitalwrite(pinledon, high);delay(150);digitalwrite(pinledon, low);delay(150);}

#define debug_enabled  1

softwareserial bluetoothserial(rxd,txd);

void setup()
{
 
    ledoff();
    serial.begin(9600);
    pinmode(rxd, input);
    pinmode(txd, output);
    pinmode(pinledon, output);
    pinmode(pinledoff, output);
    pinmode(pinbuzz, output);
    delay(2000);
    setupbluetoothconnection();
    ledon();
    delay(2000);
    allled ();
    buzz()
}

void loop()
{
    char recvchar;
   
    while(1)
    {
             
     
      if(bluetoothserial.available())
        {
                   
            recvchar = bluetoothserial.read();
            serial.print(recvchar);
           
            if(recvchar == 'a')
            {
                ledon();
            }
            else if(recvchar == 'b')
            {
                ledoff();
            }
        }
    }
}

void setupbluetoothconnection()
{
    bluetoothserial.begin(38400);  //38400                         // set bluetoothbee baudrate default baud rate 38400
    bluetoothserial.print("\r\n+stwmod=0\r\n");             // set bluetooth work in slave mode
    bluetoothserial.print("\r\n+stna=bt\r\n");            // set bluetooth name "seeedbtslave"
    bluetoothserial.print("\r\n+stoaut=1\r\n");             // permit paired device connect me
    bluetoothserial.print("\r\n +stpin=0000\r\n");          // pin
    bluetoothserial.print("\r\n+stauto=0\r\n");             // auto-connection should forbidden here
    delay(2000); +                                          // delay required.
    bluetoothserial.print("\r\n+inq=1\r\n");                // make slave bluetooth inquirable
    serial.println("the slave bluetooth inquirable!");
    delay(2000);                                            // delay required.
    bluetoothserial.flush();
}


when have arduino connected pc via usb works perfectly, when have connected battery ...


it depends on battery, power problem.


Arduino Forum > Using Arduino > Project Guidance > Control BT Arduino-Android dont work with usb conect


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support