RuiViana

Increm_Decrem_IR

Jul 15th, 2016
162
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <IRremote.h>
  2. int RECV_PIN = 11;
  3. int pin1 = 10, pin2 = 9, pin3 = 8, pin4 = 7, pin5 = 6;
  4. IRrecv irrecv(RECV_PIN);
  5. decode_results results;
  6.   int Flag = 0;
  7. //--------------------------------
  8. void setup()
  9. {
  10.   Serial.begin(9600);
  11.   irrecv.enableIRIn();
  12.   pinMode(pin1, OUTPUT);
  13.   pinMode(pin2, OUTPUT);
  14.   pinMode(pin3, OUTPUT);
  15.   pinMode(pin4, OUTPUT);
  16.   pinMode(pin5, OUTPUT);
  17.   pinMode(RECV_PIN, INPUT);
  18. }
  19. //----------------------------------
  20. void loop()
  21. {
  22.   if (irrecv.decode(&results))
  23.   {
  24.     Serial.println(results.value, HEX);
  25.     if (results.value = 0x20DF40BF)
  26.     {
  27.       Flag ++;
  28.       if (Flag > 5) Flag = 0;
  29.       irrecv.resume();
  30.     }
  31.     if (results.value = 0x20202020)    // << ---- Coloque aqui o valor do outro botão
  32.     {
  33.       Flag --;
  34.       if (Flag < 0) Flag = 5;
  35.       irrecv.resume();
  36.     }
  37.   }
  38.     switch(Flag)
  39.     {
  40.     case 0:
  41.       digitalWrite(pin1, HIGH);
  42.       digitalWrite(pin2, LOW);
  43.       digitalWrite(pin3, LOW);
  44.       digitalWrite(pin4, LOW);
  45.       digitalWrite(pin5, LOW);
  46.       break;
  47.     case 1:
  48.       digitalWrite(pin1, LOW);
  49.       digitalWrite(pin2, HIGH);
  50.       digitalWrite(pin3, LOW);
  51.       digitalWrite(pin4, LOW);
  52.       digitalWrite(pin5, LOW);
  53.       break;
  54.     case 2:
  55.       digitalWrite(pin1, LOW);
  56.       digitalWrite(pin2, LOW);
  57.       digitalWrite(pin3, HIGH);
  58.       digitalWrite(pin4, LOW);
  59.       digitalWrite(pin5, LOW);
  60.       break;
  61.     case 3:
  62.       digitalWrite(pin1, LOW);
  63.       digitalWrite(pin2, LOW);
  64.       digitalWrite(pin3, LOW);
  65.       digitalWrite(pin4, HIGH);
  66.       digitalWrite(pin5, LOW);
  67.       break;
  68.     case 4:
  69.       digitalWrite(pin1, LOW);
  70.       digitalWrite(pin2, LOW);
  71.       digitalWrite(pin3, LOW);
  72.       digitalWrite(pin4, LOW);
  73.       digitalWrite(pin5, HIGH);
  74.       break;
  75.     }
  76. }
RAW Paste Data