Go Down

Topic: Read data from mobile phone (Read 669 times) previous topic - next topic


I would like to write a program for Arduino BT that waits until a mobile phone sends it some data over bluetooth and then does something (like switches on the LED). I understand that BT communication can be done over serial interface, but I am wondering if it needs any preconfiguration on the Arduino side. I copied this code from one of the examples and adapted it, I'd like to know if I have to add something to the setup method:

Code: [Select]

int FLASH=13;
int val = 0;

void setup()
 pinMode(FLASH, OUTPUT);

void loop()
 if (Serial.available())
   val = Serial.read();
   if (val >= 0)
   { digitalWrite(FLASH, HIGH);
   } else
   { digitalWrite(FLASH, LOW);

Thanks in advance.

Go Up