Bluetooth SWITCH CASE


#1

Hi I am trying to use the Me-Bluetooth Module along with the Android Software and am running into a problem when controlling the small tank.

When look at the example code in the sketch “TestSlaveBluetoothBySoftSerial.ino” it will Serial.print Char variables in sets of (2) such as “FF” or “SS”. However, it seems like it is actually sending them (1) byte at a time, and when I try to set up a switch case it is only picking up the first byte.
Example:
I press the “Forward” button on my android and it sends the following signal:
Binary:0100011001000110
Decimal: 7070
ASCII: FF

When I set up my switch case statement:
char inBTData

if(bluetooth.available()){inBTData= bluetooth.read();}//all in ASCII
      {
      
          switch(inBTData) //read BT button
          {
           
            
            case 7070: LCDPrint(“Press UP.”,“FORWARD”);//7070=FF

It is not recognizing the case as it is only reading the first Byte
Binary:01000110
Decimal: 70
ASCII: F

Any ideas on how to best control a robot using the bluetooth as opposed to the IR?


#2

hi,you can try this code.

char inBTData[2];
int index=0;
void loop(){
if(bluetooth.available()){
    if(index>1){index=0;}
    inBTData[index]= bluetooth.read();
    index++;
     if(inBTData[0]=='F'&&inBTData[1]=='F'){
         LCDPrint("Press UP.","FORWARD");
       }
    }
  }

#3