String myCommand; void setup() { Serial.begin(9600); pinMode(3, OUTPUT);// the pins 3,4,5,6 are set to output mode pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); } //-----------------------------------------------------------------------// void loop() { while (Serial.available()){ //Checks if any byte is there to read delay(10); //it delays the serial by 10 millisecond char c = Serial.read(); //Conduct a serial read myCommand += c; //it builds the string with our commands } if (myCommand.length() > 0) { Serial.println(readvoice); if(rmyCommand == "a") // pin 3 will be high if command is a { digitalWrite(3,HIGH); digitalWrite(4,LOW); digitalWrite(5,LOW); digitalWrite(6,LOW); delay(100); } else if(myCommand == "b") //pin 4 will be high if command is b { digitalWrite(3,LOW); digitalWrite(4,HIGH); digitalWrite(5,LOW); digitalWrite(6,LOW); delay(100); } else if (myCommand == "c")//pin 5 will be high if command is c { digitalWrite(3,LOW); digitalWrite(4,LOW); digitalWrite(5,HIGH); digitalWrite(6,LOW); delay (100); } else if ( myCommand == "fan")//pin 6 will be high if command is fan { digitalWrite(3,LOW); digitalWrite(4,LOW); digitalWrite(5,LOW); digitalWrite(6,HIGH); delay (100); } else if( myCommand == "d")//pin 6 will be high if command is d since the fan command may be unreadable by google voice sometimes { digitalWrite(3,LOW); digitalWrite(4,LOW); digitalWrite(5,LOW); digitalWrite(6,HIGH); delay (100); } else if ( myCommand == "all")//all pins will be high if command is all { digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); delay (100); } else if ( myCommand == "off")//all pins will be low if command is b { digitalWrite(3,LOW); digitalWrite(4,LOW); digitalWrite(5,LOW); digitalWrite(6,LOW); delay (100); } myCommand="";}} // this resets the variable myCommand //CODED BY KALLOL