controlling of led using Bluetooth through string compare


 controlling of led using Bluetooth and Arduino through string compare 




code Arduino program



String data;

void root(String );
void setup()
{
  pinMode(13,OUTPUT);
  digitalWrite(13,LOW);
  Serial.begin(9600);
 
}
void loop()
{
  root(data);
  if(Serial.available())
  {
    data=Serial.readString();
    Serial.println(data);
    if(data== '4')
    digitalWrite(13,HIGH);
    else
    digitalWrite(13,LOW);
   
  }
}

void root(String data1)
{
  String str="mystringname";
if(Serial.available())
{
  String data1=Serial.readString();
 // Serial.write(data1);
  Serial.println(data1);
  if(data1==str)
  {
    digitalWrite(13,HIGH);
  }
    else
   {
    digitalWrite(13,LOW);
  }
}
}




OUTPUT


13 th led will high when you enter my stringname

Comments

Popular posts from this blog

MQTT basic publish and subscribe commutation each other

WifFI basics for esp32 and esp8266

controlling of led using voice commonds using bluetooth