Arduino Voice Control APP
Arduino的示例代碼(Arduino的示例代碼):
ReadString字符串=“”;
的#define LED 13 //
空隙設置(){
在pinmo(LED,OUTPUT);
digitalwrit(發光二極管,LOW);
Serial.beg的(9600);
}
空隙環(){
而(Serial.availabl A()){
炭C =(char)的Serial.read();
ReadString + = C;
}
如果(readstring.length()> 0){
如果(ReadString ==“打開”){
digitalwrit(發光二極管,HIGH);
Serial.print(“打開”);
}
否則,如果(ReadString ==“關”){
digitalwrit(發光二極管,LOW);
Serial.print(“關閉”);
}
否則,如果(ReadString ==“非常幾間房子”){
//度計算處理等。
Serial.print(“家現在21度”);
}
否則,如果(ReadString ==“講英語”){
Serial.print(“嗨,你怎麼樣?”);
}
否則{
Serial.print(“我不明白你。”);
}
ReadString =“”;
}
延遲(100);
}