Go Down

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

OAnimal

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);
 Serial.begin(115200);
 
}

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


Thanks in advance.

Go Up