Bluetooth controlled led


circuit diagram:



pin connection :

  1. led1 --2
  2. led2 --3
  3. led3 --4
  4. Tx of bluetooth -- Rx of arduino
  5. Rx of bluetooth -- Tx of arduino

App used for controll the led 


Download the app by click here 


code for the project

  int led1 = 2;
int led2 = 3;
int led3 = 4;

char val;
void setup()

pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
Serial.begin(9600);
}

void loop()
{
  while (Serial.available() > 0)
  {
  val = Serial.read();
  Serial.println(val);
  }

  if( val == 'a') // led1 on
    {
      digitalWrite(led1,HIGH);
    }
   
  else if(val == 'b') //led2 on
    {
     digitalWrite(led2,HIGH);
    }
    else if(val == 'c') // led3 on
    {
     digitalWrite(led3,HIGH);
    }
    else if(val == 'd') // led1 off
    {
     digitalWrite(led1,LOW);
    }
    else if(val == 'e') // led2 off
    {
     digitalWrite(led2,LOW);
    }
    else if(val == 'f') // led3 off
    {
     digitalWrite(led3,LOW);
    }






youtube tutorial:



No comments:

Post a Comment

Timer control led using esp32

...