#include<SoftwareSerial.h>
//SoftwareSerial mySerial(3, 4); // RX, TX
String voice;
int led1 = 5; //Connect LED 4 To Pin #13
void setup() {
Serial.begin(9600);
pinMode(led1, OUTPUT);
//pinMode(led2, OUTPUT);
// pinMode(led3, OUTPUT);
}
//-----------------------------------------------------------------------//
void loop() {
while (Serial.available()){ //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = Serial.read(); //Conduct a serial read
if (c == '#') {break;} //Exit the loop when the # is detected after the word
voice += c; //Shorthand for voice = voice + c
}
if (voice.length() > 0) {
Serial.println(voice);
//----------Turn On One-By-One----------//
if(voice == "*LIGHT ON") {digitalWrite(led1, HIGH);}
//----------Turn Off One-By-One----------//
else if(voice == "*LIGHT OFF") {digitalWrite(led1, LOW);}
//-----------------------------------------------------------------------//
voice="";}} //Reset the variable after initiating
What error i am doing because when i am giving command from phone the light is not getting ON