how to receive the bluetooth signal from phone?

Hyunkyum

New member
Nov 27, 2013
2
0
1
include <SoftwareSerial.h>
int bluetoothTx = 2;
int bluetoothRx = 3;
int LED=13;
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup() { //Setup usb serial connection to computer
Serial.begin(9600); //Setup Bluetooth serial connecti/on to android
delay(100);
bluetooth.begin(9600);
pinMode(LED, OUTPUT);
}
void loop() {
if(bluetooth.available()) {
char cmd = (char)bluetooth.read();
if(cmd == 'u') {
Serial.println("Red LED ON!");
digitalWrite(LED, HIGH);
}
if(cmd == 'd') {
Serial.println("Red LED OFF");
digitalWrite(LED, LOW);
}
}
}


In this source, I used an application named 'bluetooth serieal controller' to control the arduino.

I want to receive a signal automatically from phone when the phone is ringing.
Then, the led has to turn on.
After the phone's ring is off, the led has to turn off.

Please modify this source:(
Thank you!!
 
Back
Top