void loop() {
Serial.println("Press 1 to turn Arduino pin 13 LED ON or 0 to turn it OFF:");
while (!Serial.available()); // stay here so long as COM port is empty
INBYTE = Serial.read(); // read next available byte
if( INBYTE == '0' ) digitalWrite(LED, LOW); // if it's a 0 (zero) tun LED off
if( INBYTE == '1' ) digitalWrite(LED, HIGH); // if it's a 1 (one) turn LED on
delay(50);
}
When i connect my android device through blueterm app it prints the following statement "Press 1 to turn Arduino pin 13 LED ON or 0 to turn it OFF" as the code above, but when i send 1 or 0 nothing happens. Please help.
if(Serial.available() > 0)
{
INBYTE = Serial.read(); // read next available byte
if( INBYTE == '0' ) digitalWrite(LED, LOW); // if it's a 0 (zero) tun LED off
if( INBYTE == '1' ) digitalWrite(LED, HIGH); // if it's a 1 (one) turn LED on
delay(50);
}
}
Still nothing happens when i pass 1 or 0 through my device. Does transmitting serial data through rx of arduino cause any problem. I have heard its used for usb debugging too. So does it interefere with me passing 1 or 0?
Are you using both the serial monitor with the USB cable still plugged in and the bluetooth module? Use one or the other, and maybe use Putty to another terminal program to send the commands.
All capital letters for a name is, by convention, reserved for constants. You can not assign a value to a constant, so, without careful reading, your code looks wrong.
char INBYTE;
is a horrid name. I expect I'd find statements like:
int myFloat;
float chars[10];
etc. later in your code.
A name like inChar makes a lot more sense.
As does the suggestion to put all the code in an if(Serial.available() > 0) block.
Quite a few people have been having issues using Blueterm and HC-05/06 modules. Try a different terminal program then, try Putty or Realterm on your computer, to see if the BT module is working properly, then try the phone.