This is a android apps to control Three switch or relay with arduino board. This is a simple example apps to control anything. We give with code to operate and make a tutorial to use and learn about Android and Arduino Bluetooth communication.
The Arduino code is
char blueToothVal; //value sent over via bluetooth
char lastValue; //stores last state of device (on/off)
int led = 9;
int ledone = 2;
int ledtwo = 3;
void setup()
{
Serial.begin(9600);
pinMode(led,OUTPUT);
pinMode(ledone, OUTPUT);
pinMode(ledtwo, OUTPUT);
}
void loop()
{
if(Serial.available())
{//if there is data being recieved
blueToothVal=Serial.read(); //read it
}
if (blueToothVal=='n')
{//if value from bluetooth serial is n
digitalWrite(led,HIGH); //switch on LED
if (lastValue!='n')
Serial.println(F("LED 1 is on")); //print LED is on
lastValue=blueToothVal;
}
else if (blueToothVal=='f')
{//if value from bluetooth serial is n
digitalWrite(led,LOW); //turn off LED
if (lastValue!='f')
Serial.println(F("LED 1 is off")); //print LED is on
lastValue=blueToothVal;
}
if (blueToothVal=='a')
{//if value from bluetooth serial is n
digitalWrite(ledone,HIGH); //switch on LED
if (lastValue!='a')
Serial.println(F("led 2 is on")); //print LED is on
lastValue=blueToothVal;
}
else if (blueToothVal=='b')
{//if value from bluetooth serial is n
digitalWrite(ledone,LOW); //turn off LED
if (lastValue!='b')
Serial.println(F("led 2 is off")); //print LED is on
lastValue=blueToothVal;
}
if (blueToothVal=='c')
{//if value from bluetooth serial is n
digitalWrite(ledtwo,HIGH); //switch on LED
if (lastValue!='c')
Serial.println(F("led 3 is on")); //print LED is on
lastValue=blueToothVal;
}
else if (blueToothVal=='d')
{//if value from bluetooth serial is n
digitalWrite(ledtwo,LOW); //turn off LED
if (lastValue!='d')
Serial.println(F("led 3 is off")); //print LED is on
lastValue=blueToothVal;
}
delay(1000);
}
You can Learn by Bangla tutorial on http://workitbd.com/page.php?86