Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <IRremote.h>
- int RECV_PIN = 11;
- int pin1 = 10, pin2 = 9, pin3 = 8, pin4 = 7, pin5 = 6;
- IRrecv irrecv(RECV_PIN);
- decode_results results;
- int Flag = 0;
- //--------------------------------
- void setup()
- {
- Serial.begin(9600);
- irrecv.enableIRIn();
- pinMode(pin1, OUTPUT);
- pinMode(pin2, OUTPUT);
- pinMode(pin3, OUTPUT);
- pinMode(pin4, OUTPUT);
- pinMode(pin5, OUTPUT);
- pinMode(RECV_PIN, INPUT);
- }
- //----------------------------------
- void loop()
- {
- if (irrecv.decode(&results))
- {
- Serial.println(results.value, HEX);
- if (results.value = 0x20DF40BF)
- {
- Flag ++;
- if (Flag > 5) Flag = 0;
- irrecv.resume();
- }
- if (results.value = 0x20202020) // << ---- Coloque aqui o valor do outro botão
- {
- Flag --;
- if (Flag < 0) Flag = 5;
- irrecv.resume();
- }
- }
- switch(Flag)
- {
- case 0:
- digitalWrite(pin1, HIGH);
- digitalWrite(pin2, LOW);
- digitalWrite(pin3, LOW);
- digitalWrite(pin4, LOW);
- digitalWrite(pin5, LOW);
- break;
- case 1:
- digitalWrite(pin1, LOW);
- digitalWrite(pin2, HIGH);
- digitalWrite(pin3, LOW);
- digitalWrite(pin4, LOW);
- digitalWrite(pin5, LOW);
- break;
- case 2:
- digitalWrite(pin1, LOW);
- digitalWrite(pin2, LOW);
- digitalWrite(pin3, HIGH);
- digitalWrite(pin4, LOW);
- digitalWrite(pin5, LOW);
- break;
- case 3:
- digitalWrite(pin1, LOW);
- digitalWrite(pin2, LOW);
- digitalWrite(pin3, LOW);
- digitalWrite(pin4, HIGH);
- digitalWrite(pin5, LOW);
- break;
- case 4:
- digitalWrite(pin1, LOW);
- digitalWrite(pin2, LOW);
- digitalWrite(pin3, LOW);
- digitalWrite(pin4, LOW);
- digitalWrite(pin5, HIGH);
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement