Advertisement
RuiViana

Controle remoto

Jul 27th, 2015
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. /*
  2. * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
  3. * An IR detector/demodulator must be connected to the input RECV_PIN.
  4. * Version 0.1 July, 2009
  5. * Copyright 2009 Ken Shirriff
  6. * http://arcfn.com
  7. */
  8.  
  9. #include <IRremote.h>
  10. int flag = 0;
  11.  
  12. int RECV_PIN = 13;
  13. const int rele1=8;
  14. const int rele2=9;
  15. const int rele3=10;
  16. const int rele4=11;
  17. const int rele5=12;
  18. const int ant1=4;
  19. const int ant2=5;
  20. const int ant3=6;
  21. const int ant4=7;
  22.  
  23. IRrecv irrecv(RECV_PIN);
  24.  
  25. decode_results results;
  26.  
  27. void setup()
  28. {
  29. Serial.begin(9600);
  30. pinMode (8,OUTPUT);
  31. pinMode (9,OUTPUT);
  32. pinMode (10,OUTPUT);
  33. pinMode (11,OUTPUT);
  34. pinMode (12,OUTPUT);
  35. pinMode (4,OUTPUT);
  36. pinMode (5,OUTPUT);
  37. pinMode (6,OUTPUT);
  38. pinMode (7,OUTPUT);
  39.  
  40. irrecv.enableIRIn(); // Start the receiver
  41. }
  42.  
  43. void loop() {
  44. if (irrecv.decode(&results)) {
  45. Serial.println(results.value, DEC);
  46.  
  47.  
  48. if(results.value==1808161144){ // tecla_1
  49. digitalWrite(ant1,HIGH); // ant1 liga__desliga 2,3,4
  50. digitalWrite(ant2,LOW);
  51. digitalWrite(ant3,LOW);
  52. digitalWrite(ant4,LOW);
  53.  
  54.  
  55. }
  56.  
  57. if(results.value==1935374717){ // tecla_2
  58. digitalWrite(ant2,HIGH); // rele2 liga__desliga 1,3,4
  59. digitalWrite(ant1,LOW);
  60. digitalWrite(ant3,LOW);
  61. digitalWrite(ant4,LOW);
  62.  
  63.  
  64. }
  65.  
  66. if(results.value==516431292){ // tecla_3
  67. digitalWrite(ant3,HIGH); // rele3 liga__desliga 1,2,4
  68. digitalWrite(ant1,LOW);
  69. digitalWrite(ant2,LOW);
  70. digitalWrite(ant4,LOW);
  71.  
  72.  
  73. }
  74. if(results.value==1158108117){ // tecla_4
  75. digitalWrite(ant4,HIGH); // rele4 liga__desliga 1,2,3
  76. digitalWrite(ant1,LOW);
  77. digitalWrite(ant2,LOW);
  78. digitalWrite(ant3,LOW);
  79.  
  80.  
  81. }
  82.  
  83. if(results.value==584651448){ // vol +
  84. digitalWrite(rele1,HIGH);
  85.  
  86. }
  87.  
  88. if(results.value==2003594873){ // vol -
  89. digitalWrite(rele1,LOW);
  90.  
  91.  
  92.  
  93. }
  94.  
  95. if(results.value==3569241652){ // prev ch
  96. digitalWrite(rele2,HIGH);
  97. }
  98. if(results.value==2464142364){ // mute
  99. digitalWrite(rele2,LOW);
  100.  
  101. }
  102.  
  103. if(results.value==2420009732){ // chan +
  104. digitalWrite(rele3,HIGH);
  105. }
  106.  
  107. if(results.value==1907287989){ // chan -
  108. digitalWrite(rele3,LOW);
  109.  
  110. }
  111.  
  112. if(results.value==3121565404){ // tecla_5
  113. digitalWrite(rele4,HIGH);
  114.  
  115. }
  116. if(results.value==4177530493){ // tecla_8
  117. digitalWrite(rele4,LOW);
  118.  
  119.  
  120. }
  121. if(results.value==1254415001){ // tecla_6
  122. flag = !flag;
  123. if (flag == 1)
  124. digitalWrite(rele5,HIGH);
  125. else
  126. digitalWrite(rele5,LOW);
  127.  
  128. }
  129.  
  130. irrecv.resume(); // Receive the next value
  131.  
  132.  
  133. }
  134.  
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement