ARDUINO BLUETOOTH HC05 LED CONTROL
ARDUINO BLUETOOTH HC05 LED CONTROL
This is a program used to interface and control led arduino using an hc05 bluetooth module.
BUYING LINKS TO AMAZON BELOW :
PROGRAM :
const int led1 =13;
const int led2 =12;
void setup()
{
Serial.begin(38400);
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
}
void loop()
{
if(Serial.available())
{
String value = Serial.readStringUntil("'\n");
if(value =="123")
{
Serial.write("LED ON");
digitalWrite(led1,HIGH);
}
if(value=="456")
{
Serial.write("LED OFF");
digitalWrite(led1,LOW);
}
if(value=="789")
{
Serial.write("LED 2 ON");
digitalWrite(led2,HIGH);
}
if(value=="#")
{
Serial.write("LED 2 OFF");
digitalWrite(led2,LOW);
}
}
}
Comments
Post a Comment