Arduino Code For Voice Control LED
int Green = 3;
int Orange = 4;
int Red = 5;
void setup() {
Serial.begin(9600);
pinMode(Green,OUTPUT);
pinMode(Orange,OUTPUT);
pinMode(Red,OUTPUT);
}
char c;
String voice;
void loop() {
if (Serial.available()>0)
{
voice="";
voice=Serial.readString();
Serial.print(voice+'\');
}
if(voice=="green")
{
digitalWrite(Green,HIGH);
} else if(voice=="green off")
{
digitalWrite(Green,LOW);
}
if(voice=="blue")
{
digitalWrite(Orange,HIGH);
} else if(voice=="blue off")
{
digitalWrite(Orange,LOW);
}
if(voice=="red")
{
digitalWrite(Red,HIGH);
} else if(voice=="red off")
{
digitalWrite(Red,LOW);
}
}
Comments
Post a Comment