Advertisement
RuiViana

CR_IR_Receptor

Dec 27th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.15 KB | None | 0 0
  1. #include <IRremote.h>
  2. IRsend irsend;
  3.  
  4. const int RECV_PIN = 11;
  5. const int Rele = 13;
  6. IRrecv irrecv(RECV_PIN);
  7. decode_results results;
  8.  
  9. int led = 3;
  10. int led1 = 8;
  11. int ch1 = 4;
  12. int ch2 = 5;
  13. int ch3 = 6;
  14. int ch4 = 7;
  15. unsigned int S_pwr[67]={4500,4350,650,1600,600,1600,650,450,600,500,650,500,600,500,600,1600,600,500,650,1600,600,1600,600,500,600,500,650,1600,600,500,600,1600,650,450,600,1650,600,500,600,500,600,500,600,500,650,450,650,500,600,500,600,500,600,1600,600,1650,600,1600,600,1600,600,1650,600,1600,600,1600,650,};
  16. unsigned int S_fca[67]={4550,4350,650,1600,600,1600,650,450,650,450,600,550,600,500,600,1600,650,450,600,1650,600,1600,600,500,600,500,650,1600,600,500,600,1600,650,450,600,1650,600,500,600,500,600,500,600,1600,600,550,600,500,600,500,600,500,650 ,1550,650,1600,600,1600,600,500,650,1600,600,1600,600,1600,600,};
  17. unsigned int S_vol[67]={4500,4400,600,1650,550,1650,600,500,600,500,600,500,600,550,600,1600,600,500,600,1600,600,1650,600,500,600,500,600,1600,600,550,600,1600,600,500,600,1600,600,1650,600,500,600,1600,600,1650,600,1600,600,500,600,500,600,500,600,550,600,1600,600,500,600,500,600,550,550,1650,600,1600,600,};
  18. unsigned int S_volm[67]={4500,4400,600,1600,600,1650,600,500,600,500,600,500,600,500,600,1650,600,500,600,1600,600,1650,600,500,600,500,600,1600,600,500,600,1650,600,500,600,1600,600,1650,600,500,600,500,600,1600,600,1650,600,500,600,500,600,500,600,500,600,1650,600,1600,600,500,600,500,600,1650,600,1600,600,};
  19. unsigned int S_ant[67]={4500,4400,600,1650,550,1650,600,500,600,500,600,500,600,550,600,1600,600,500,600,1600,600,1650,600,500,600,500,600,1600,600,550,600,1600,600,500,600,1600,600,1650,550,550,600,1600,600,1650,600,500,600,500,550,550,600,500,600,550,550,1650,600,500,600,500,600,1650,550,1650,600,1600,600,};
  20. unsigned int S_ava[67]={4500,4400,550,1650,600,1600,600,500,600,500,600,550,600,500,600,1600,600,500,600,1650,600,1600,600,500,600,500,600,1650,600,500,600,1600,600,500,600,1650,600,1600,600,500,600,500,600,1650,600,500,550,550,600,500,600,500,600,500,600,1650,600,1600,600,500,600,1650,600,1600,550,1650,600,};
  21. unsigned int S_pla[67]={4500,4400,550,1650,600,1600,600,500,600,500,600,550,600,500,600,1600,600,500,600,1650,600,1600,600,500,600,500,600,1650,600,500,600,1600,600,500,600,1650,600,1600,600,500,600,500,600,1650,600,500,550,550,600,500,600,500,600,500,600,1650,600,1600,600,500,600,1650,600,1600,550,1650,600,};
  22. unsigned int S_cim[67]={4500,4400,550,1700,550,1650,550,550,550,550,550,600,550,550,550,1650,550,550,550,1700,550,1650,550,550,550,550,550,1700,550,550,550,1650,550,600,550,1650,550,550,550,1650,550,1700,550,550,550,550,550,550,550,600,550,550,550,1650,550,550,550,600,550,1650,550,1650,550,1700,550,1650,550,};
  23. unsigned int S_bai[67]={4550,4350,650,1600,600,1600,650,450,600,500,650,450,650,500,600,1600,650,450,650,1600,600,1600,650,450,650,450,650,1600,600,500,650,1550,600,500,650,1600,600,500,650,1550,650,500,600,500,600,500,650,450,650,450,650,500,600,1600,600,500,650,1550,650,1600,600,1600,600,1650,600,1600,600,};
  24. //---------------------------------------------------------
  25. void setup()
  26. {
  27. Serial.begin(9600);
  28. pinMode(led,OUTPUT); //infravermelho;
  29. pinMode(led1,OUTPUT);//infravermelho2;
  30. pinMode(ch1, OUTPUT);//Pino digital saída do Arduino(4-ch1);
  31. pinMode(ch2, OUTPUT);//Pino digital saída do Arduino(5-ch2);
  32. pinMode(ch3, OUTPUT);//Pino digital saída do Arduino(6-ch3);
  33. pinMode(ch4, OUTPUT);//Pino digital saída do Arduino(7-ch4);
  34.  
  35. pinMode(Rele,OUTPUT);
  36. irrecv.enableIRIn();
  37. }
  38. //---------------------------------------------------------
  39. void loop()
  40. {
  41. if (irrecv.decode(&results))
  42. {
  43. Serial.println(results.value, HEX);
  44. if(results.value == 0xFFA25D)
  45. {
  46. digitalWrite(Rele, HIGH);
  47. }
  48. if(results.value == 0xFF629D)
  49. {
  50. digitalWrite(Rele, LOW);
  51. }
  52. irrecv.resume();
  53. }
  54. if (Serial.available() > 0)
  55. {
  56. char valorlido = Serial.read();
  57. //Controle da tv //
  58. switch(valorlido)
  59. {
  60. case 'a': irsend.sendNEC (0x2FD48B7, 32);break; // Power break;
  61. case 'b': irsend.sendNEC (0x2FDF00F, 32);break; // Input;
  62. case 'c': irsend.sendNEC (0x2FD01FE, 32);break; // Menu;
  63. case 'd': irsend.sendNEC (0x2FD41BE, 32);break; // Tecla Cima;
  64. case 'e': irsend.sendNEC (0x2FDC13E, 32);break; // Tecla Baixo;
  65. case 'f': irsend.sendNEC (0x2FDB847, 32);break; // Tecla Esquerda;
  66. case 'g': irsend.sendNEC (0x2FD9867, 32);break; // Tecla Direita;
  67. case 'h': irsend.sendNEC (0x2FD58A7, 32);break; // Volume +;
  68. case 'i': irsend.sendNEC (0x2FD7887, 32);break; // Volume -;
  69. case 'j': irsend.sendNEC (0x2FDD827, 32);break; // Canal +;
  70. case 'k': irsend.sendNEC (0x2FDF807, 32);break; // Canal -;
  71. case 'l': irsend.sendNEC (0x2FD08F7, 32);break; // Mute;
  72. case 'z': irsend.sendNEC (0x2FD916E, 32);break; // Enter;
  73. case 'A': irsend.sendNEC (0x2FD20DF, 32);break; // Sbt:
  74. case 'B': irsend.sendNEC (0x2FDA05F, 32);break; // Globo:
  75. case 'C': irsend.sendNEC (0x2FDE01F, 32);break; // Record:
  76. case 'D': irsend.sendNEC (0x2FD906F, 32);break; // Rede tv:
  77.  
  78. //Controle Home;
  79. case 'G': irsend.sendRaw (S_pwr,67, 38);break; // Power break;
  80. case 'H': irsend.sendRaw (S_fca,67, 38);break; // funcao;
  81. case 'I': irsend.sendRaw (S_vol,67, 38);break; // Volume - ;
  82. case 'J': irsend.sendRaw (S_volm,67, 38);break; // Volume +;
  83. case 'K': irsend.sendRaw (S_volm,67, 38);break; // anterior;
  84. case 'L': irsend.sendRaw (S_ava,67, 38);break; // avancar;
  85. case 'M': irsend.sendRaw (S_pla,67, 38);break; //play;
  86. case 'N': irsend.sendRaw (S_cim,67, 38);break; //cima;
  87. case 'O': irsend.sendRaw (S_bai,67, 38);break;//baixo;
  88.  
  89. //FITA DE LED;
  90. case 'm': irsend.sendNEC (0xFF02FD, 32);break; // Power;
  91. case 'n': irsend.sendNEC (0xFF3AC5, 32);break; // Aumentar Brilho;
  92. case 'o': irsend.sendNEC (0xFFBA45, 32);break; // Diminuir Brilho;
  93. case 'p': irsend.sendNEC (0xFF9A65, 32);break; // Vermelho;
  94. case 'q': irsend.sendNEC (0xFF1AE5, 32);break; // Verde;
  95. case 'r': irsend.sendNEC (0xFFA25D, 32);break; // Azul;
  96. case 's': irsend.sendNEC (0xFF22DD, 32);break; // Branco;
  97. case 't': irsend.sendNEC (0xFFE817, 32);break; // + Velocidade;
  98. case 'u': irsend.sendNEC (0xFFC837, 32);break; // - Velocidade;
  99. case 'v': irsend.sendNEC (0xFFF00F, 32);break; // Auto;
  100. case 'y': irsend.sendNEC (0xFFD02F, 32);break; // Flash;
  101. case 'x': irsend.sendNEC (0xFFE01F, 32);break; // Efeito 1;
  102. case 'w': irsend.sendNEC (0xFF609F, 32);break; // Efeito 2;
  103. //LAMPADAS:
  104.  
  105. //CANAL 1//
  106. case '1':digitalWrite(ch1, !digitalRead(ch1));break;//Quarto;
  107. case '5':digitalWrite(ch2, !digitalRead(ch2));break;//NULO;
  108. case '3':digitalWrite(ch3, !digitalRead(ch3));break;//escada;
  109. case '4':digitalWrite(ch4, !digitalRead(ch4));break; // Banheiro
  110. }
  111. irrecv.enableIRIn();
  112. }
  113. delay(10);
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement