Compare char with integers

if(bluetooth.available()) // If the bluetooth sent any characters { // Send any characters the bluetooth prints to the serial monitor Serial.println((char)bluetooth.read());

if ((char)bluetooth.read() == 3){ ledOn(); } if ((char)bluetooth.read() == 4){ ledOff(); } } if(Serial.available()) { bluetooth.println((char)Serial.read()); bluetooth.println("Serial got something"); } }

I have sent in the value into the bluetooth from my mobile phone. I can recieve the value on the serial using char. However I cannot read the value or turn on my LED with this current code. Anyone knows how to compare them properly?

If your comparing the ASCII character 3 then you need to put it in ' marks

      if ((char)bluetooth.read() == '3'){

      if ((char)bluetooth.read() == '4'){

Yes i did that. But my arduino UNO occasionally it does received the data but sometime it did not. which now I am wondering if it is my arduino UNO who is causing the problem :confused:

However I cannot read the value or turn on my LED with this current code

You can't do anything with that code, because it cannot possibly compile. (No setup, loop or main)

It's more likely that it's your code than your Arduino. If you post it (and use code tags instead of quote tags), we can have a look at it.