Code
Code
int i;
char c;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
while(strstr(msg, "ON")) {
digitalWrite(13, HIGH);
delay(5000);
digitalWrite(13, LOW);
memset(&msg[0], 0, sizeof(msg));
i = 0;
}
while(strstr(msg, "OFF")) {
digitalWrite(13, LOW);
memset(&msg[0], 0, sizeof(msg));
i = 0;
}
while (Serial.available()) {
c = Serial.read();
if(i>200){
memset(&msg[0], 0, sizeof(msg));
i = 0;
}
else{
msg[i++]=c;
}
}
}