TalkBack string newCommand?
Show older comments
TalkBack not work for ON/OFF LED with ESP8266, because wrong use for string newCommand
int z = newCommand.length();
then
compare z with 17 for TURN_ON and
compare z with 18 for TURN+OFF
for nothing new z=5
if( z > 5){
if(z == 17){
digitalWrite(LED_BUILTIN, LOW);
Serial.println("LED_ON");
}
if(z == 18){
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("LED_OFF");
}
}
else{
Serial.println(" Nothing new.");
}
Answers (1)
ASSET
on 28 May 2023
0 votes
Solution is this: if(newCommand.length() != 0) Serial.print ("Latest command from queue: “); Serial.printIn (newCommand); if (newCommand.indexOf ("TURN ON") > 0) { digitalWrite (2, HIGH); if(newCommand.indexOf ("TURN_OFF") > 0) { digitalWite (2, LOW); }
Categories
Find more on Signal Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!