Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://labdegaragem.com/forum/topics/comando-de-voz-com-ardu-no-e-bluetooth
- String voz;
- int
- led1 = 9,
- led2 = 10,
- led3 = 11,
- led4 = 12,
- led5 = 13,
- led6 = 4,
- led7 = 5,
- led8 = 6,
- led9 = 7,
- led10 = 8;
- void allon(){
- digitalWrite(led1, HIGH);
- digitalWrite(led2, HIGH);
- digitalWrite(led3, HIGH);
- digitalWrite(led4, HIGH);
- digitalWrite(led5, HIGH);
- digitalWrite(led6, HIGH);
- digitalWrite(led7, HIGH);
- digitalWrite(led8, HIGH);
- digitalWrite(led9, HIGH);
- digitalWrite(led10, HIGH);
- }
- void alloff(){
- digitalWrite(led1, LOW);
- digitalWrite(led2, LOW);
- digitalWrite(led3, LOW);
- digitalWrite(led4, LOW);
- digitalWrite(led5, LOW);
- digitalWrite(led6, LOW);
- digitalWrite(led7, LOW);
- digitalWrite(led8, LOW);
- digitalWrite(led9, LOW);
- digitalWrite(led10, LOW);
- }
- void setup() {
- Serial.begin(9600);
- pinMode(led1, OUTPUT);
- pinMode(led2, OUTPUT);
- pinMode(led3, OUTPUT);
- pinMode(led4, OUTPUT);
- pinMode(led5, OUTPUT);
- pinMode(led6, OUTPUT);
- pinMode(led7, OUTPUT);
- pinMode(led8, OUTPUT);
- pinMode(led9, OUTPUT);
- pinMode(led10, OUTPUT);
- }
- void loop() {
- while (Serial.available()){
- delay(10);
- char c = Serial.read();
- voz += c;
- }
- if (voz.length() > 0) {
- Serial.println(voz);
- if(voz == "ligar tudo" ) {allon();}
- else if(voz == "desligar tudo"){alloff();}
- else if(voz == "ligar lâmpada 1") {digitalWrite(led1, HIGH);}
- else if(voz == "ligar lâmpada 2") {digitalWrite(led2, HIGH);}
- else if(voz == "ligar lâmpada 3") {digitalWrite(led3, HIGH);}
- else if(voz == "ligar lâmpada 4") {digitalWrite(led4, HIGH);}
- else if(voz == "ligar lâmpada 5") {digitalWrite(led5, HIGH);}
- else if(voz == "ligar lâmpada 6") {digitalWrite(led6, HIGH);}
- else if(voz == "ligar lâmpada 7") {digitalWrite(led7, HIGH);}
- else if(voz == "ligar lâmpada 8") {digitalWrite(led8, HIGH);}
- else if(voz == "ligar lâmpada 9") {digitalWrite(led9, HIGH);}
- else if(voz == "ligar lâmpada 10")
- {
- digitalWrite(led10, HIGH);
- delay(3000);
- digitalWrite(led10, LOW);
- }
- else if(voz == "desligar lâmpada 1") {digitalWrite(led1, LOW);}
- else if(voz == "desligar lâmpada 2") {digitalWrite(led2, LOW);}
- else if(voz == "desligar lâmpada 3") {digitalWrite(led3, LOW);}
- else if(voz == "desligar lâmpada 4") {digitalWrite(led4, LOW);}
- else if(voz == "desligar lâmpada 5") {digitalWrite(led5, LOW);}
- else if(voz == "desligar lâmpada 6") {digitalWrite(led6, LOW);}
- else if(voz == "desligar lâmpada 7") {digitalWrite(led7, LOW);}
- else if(voz == "desligar lâmpada 8") {digitalWrite(led8, LOW);}
- else if(voz == "desligar lâmpada 9") {digitalWrite(led9, LOW);}
- voz="";}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement