?? ???? Arduino ???? Android ?? Bluetooth ?? ??????? ???????? Contorl ?????
?? ????? ???? ????????
? ?? Arduino
? ?? Bluetooth Module
2/3 ?? LED
?? ??????? ?? ???
????? ??????? ?? ??? ?? ???? Connect ??? ????? ?????? ??? ???? ???? ???? ????? ??? Bluetooth ?? ?????, ?????? LED/Relay ?? Output Connection?
Bluetooth ?? Tx pin arduino ?? Rx pin ? ?? Rx pin Arduino ?? Tx pin ? ????? ???? ???? VCC ??? GND connect ???? ?????? ?????? Bluetooth ?? ??? ????
???? Arduino ?? Digital 3, 5, 6 No pin ? LED/Relay ?? Output ?? Positive (+) ??????? ????? ???? Output ?? ???? ??????? GND ?? ????? ???? ?????? ?????? Connection Complete?
??? ?????? Code Upload ???? ????...
char blueToothVal; //value sent over via bluetooth
char lastValue; //stores last state of device (on/off)
int led = 3;
int ledone = 5;
int ledtwo = 6;
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 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 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("ledone 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("ledone 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("ledtwo 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("ledtwo is off")); //print LED is on
lastValue=blueToothVal;
}
delay(1000);
}
Code Upload ??? ???? Download ??? ??? "BShaniuno" Android Apps
Apps Install ??? ??????? ?? ??? Operate ????...