TalkBack string newCommand?
2 ビュー (過去 30 日間)
古いコメントを表示
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.");
}
0 件のコメント
回答 (1 件)
ASSET
2023 年 5 月 28 日
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); }
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!