How to make Voice Controlled LEDS

 







             CODE 

int Green = 3;

int Blue = 4;

int Red = 5;


void setup() {

  Serial.begin(9600);

  pinMode(Green,OUTPUT);

  pinMode(Blue,OUTPUT);

  pinMode(Red,OUTPUT);

  


}



char c;

String voice;


void loop() {

  if (Serial.available()>0)

  {

    voice="";

    voice=Serial.readString();

    Serial.print(voice+'\n');

  }


  if(voice=="green light on")

  {

    digitalWrite(Green,HIGH);

  } else if(voice=="green light off")

  {

    digitalWrite(Green,LOW);

  }


    if(voice=="blue light on")

  {

    digitalWrite(Blue,HIGH);

  } else if(voice=="blue light off")

  {

    digitalWrite(Blue,LOW);

  }


  

  if(voice=="red light on")

  {

    digitalWrite(Red,HIGH);

  } else if(voice=="red light off")

  {

    digitalWrite(Red,LOW);

  }


}

Post a Comment

Previous Post Next Post

Contact Form