I am connecting an arduino to an Android device via bluetooth. I want the arduino to enter a different loop based on the input from the phone. I guess it would be the equivalent of a getchar function. What do I use?
Alex
I am connecting an arduino to an Android device via bluetooth. I want the arduino to enter a different loop based on the input from the phone. I guess it would be the equivalent of a getchar function. What do I use?
Alex
You would use Serial.read() to get the chars. You would have to be a little creative if you want get multiple chars or words to be recognised. Try to just do the basic LED on/off test with chars "H" and "L" first, then build up from there.
Okay thanks. I'm giving it a try right now.
It isn't working. my code looks like this:
int beep = 0;
void setup()
{
Serial.begin(115200); // connect to the serial port
}
void loop()
{
beep = Serial.read();
if (beep = '1')
{
tone(A4, 440, 1000);
delay (500);
tone(A4, 440, 1000);
delay (500);
tone(A4, 440, 1000);
delay (500);
tone(A4, 440, 1000);
delay (500);
tone(A4, 440, 1000);
delay (500);
beep = 0;
}
}
Instead of having periods when the buzzer isn't going, it just gives me a solid tone. Any ideas?
if (beep = '1')
= is the assignment operator.
== is the comparison operator.