Advertisement
RuiViana

Liga_Desliga_IR_Timer

Mar 11th, 2016
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <IRremote.h>
  2. #define RELE 12
  3. int estado_rele = HIGH;
  4. int RECV_PIN = 6;
  5. IRrecv irrecv(RECV_PIN);
  6. decode_results results;
  7.  
  8. void setup()
  9. {
  10. digitalWrite(RELE, estado_rele);
  11. pinMode(12, OUTPUT);
  12. Serial.begin(9600);
  13. irrecv.enableIRIn();
  14. }
  15.  
  16. void loop()
  17. {
  18. if (irrecv.decode(&results))
  19. {
  20. Serial.println(results.value, HEX);
  21. irrecv.resume();
  22. }
  23. if (results.value == 0x1006E)
  24. {
  25. digitalWrite(RELE,HIGH);
  26. }
  27. if (results.value == 0x6E)
  28. {
  29. digitalWrite(RELE,LOW);
  30. }
  31.  
  32. if(digitalRead(RELE)== HIGH) // Se o rele está Ligado
  33. {
  34. if (results.value == 0x1006D) // Se voce quer desligar com Timer
  35. {
  36. delay(90000); // Aguarde 1 minto e meio
  37. digitalWrite(RELE,LOW); // Desligue o rele
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement