String voice; void setup() { Serial.begin(9600); pinMode(13, OUTPUT); pinMode(12, OUTPUT); } void loop() { while (Serial.available()){ delay(10); char c = Serial.read(); if (c == '#') {break;} voice += c; } if (voice.length() > 0) { Serial.println(voice); if(voice == "*light on") {digitalWrite(13, HIGH);} else if(voice == "*light off") {digitalWrite(13, LOW);} else if(voice == "*motor on") {digitalWrite(12, HIGH);} else if(voice == "*motor of") {digitalWrite(12, LOW);} voice="";}}