Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ch1 = 1; // chave 1
- int ch2 = 2; // chave 2
- int led1 = 3; // led 1
- int led2 = 4; // led 2
- int led13 = 13;// led 13 placa
- byte comando = 0;//tipo de comando dos leds
- void setup()
- {
- pinMode(ch1, INPUT);
- pinMode(ch2, INPUT);
- pinMode(led1, OUTPUT);
- pinMode(led2, OUTPUT);
- pinMode(led13, OUTPUT);
- }
- void loop()
- {
- int leitura1 = digitalRead(ch1);
- int leitura2 = digitalRead(ch2);
- if (leitura1 == LOW && leitura2 == LOW) // 00
- {
- comando = 0;
- }
- else if (leitura1 == LOW && leitura2 == HIGH) // 01
- {
- comando = 1;
- }
- else if (leitura1 == HIGH && leitura2 == LOW) // 10
- {
- comando = 2;
- }
- else if (leitura1 == HIGH && leitura2 == HIGH) // 11
- {
- comando = 3;
- }
- switch (comando)
- {
- case 0:
- comando = 0;//comando=0
- delay(1000);
- digitalWrite(led1, LOW);
- digitalWrite(led2, LOW);
- digitalWrite(led13, HIGH);
- break;
- case 1:
- comando = 1;//comando=1
- delay(1000);
- digitalWrite(led1, LOW);
- digitalWrite(led2, HIGH);
- digitalWrite(led13, LOW);
- break;
- case 2:
- comando = 2;//comando=2
- delay(1000);
- digitalWrite(led1, HIGH);
- digitalWrite(led2, LOW);
- digitalWrite(led13, LOW);
- break;
- case 3:
- comando = 4;//comando=3
- delay(1000);
- digitalWrite(led1, HIGH);
- digitalWrite(led2, HIGH);
- digitalWrite(led13, LOW);
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement