Advertisement
RuiViana

IR do LC

Oct 23rd, 2015
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.68 KB | None | 0 0
  1. #include <IRremote.h>
  2. IRsend irsend;
  3. int RECV_PIN = 11;
  4. IRrecv irrecv(RECV_PIN);
  5.  
  6. decode_results results;
  7. int con = 9;
  8. int led = 3;
  9. int led1 = 8;
  10. int ch1 = 4;
  11. int ch2 = 5;
  12. int ch3 = 6;
  13. int ch4 = 7;
  14. 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,};
  15. 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,};
  16. 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,};
  17. 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,};
  18. 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,};
  19. 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,};
  20. 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,};
  21. 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,};
  22. 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,};
  23.  
  24. void setup()
  25. {
  26. Serial.begin(9600);
  27. irrecv.enableIRIn();
  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. void loop() {
  36. char valorlido = Serial.read();
  37. //CONTROLE UNIVERSAL//
  38. switch (results.value == 0xFFA25D) { digitalWrite(ch1, HIGH);
  39. }
  40. switch (results.value == 0xFF629D) { digitalWrite(ch1, HIGH);
  41. }
  42. switch (results.value == 0xFF629D) { digitalWrite(con, HIGH);
  43. }
  44. //Controle da tv /////SEMPRE QUE COLOCO ESSE CODIGO EM NEGRITO NAO FUNCIONA O CONTROLE///
  45. switch(valorlido)
  46. {
  47. case 'a': irsend.sendNEC (0x2FD48B7, 32); break; // Power break;
  48. case 'b': irsend.sendNEC (0x2FDF00F, 32); break; // Input;
  49. case 'c': irsend.sendNEC (0x2FD01FE, 32); break; // Menu;
  50. case 'd': irsend.sendNEC (0x2FD41BE, 32); break; // Tecla Cima;
  51. case 'e': irsend.sendNEC (0x2FDC13E, 32); break; // Tecla Baixo;
  52. case 'f': irsend.sendNEC (0x2FDB847, 32); break; // Tecla Esquerda;
  53. case 'g': irsend.sendNEC (0x2FD9867, 32); break; // Tecla Direita;
  54. case 'h': irsend.sendNEC (0x2FD58A7, 32); break; // Volume +;
  55. case 'i': irsend.sendNEC (0x2FD7887, 32); break; // Volume -;
  56. case 'j': irsend.sendNEC (0x2FDD827, 32); break; // Canal +;
  57. case 'k': irsend.sendNEC (0x2FDF807, 32); break; // Canal -;
  58. case 'l': irsend.sendNEC (0x2FD08F7, 32); break; // Mute;
  59. case 'z': irsend.sendNEC (0x2FD916E, 32); break; // Enter;
  60. case 'A': irsend.sendNEC (0x2FD20DF, 32); break; // Sbt:
  61. case 'B': irsend.sendNEC (0x2FDA05F, 32); break; // Globo:
  62. case 'C': irsend.sendNEC (0x2FDE01F, 32); break; // Record:
  63. case 'D': irsend.sendNEC (0x2FD906F, 32); break; // Rede tv:
  64.  
  65. //Controle Home;
  66. case 'G': irsend.sendRaw (S_pwr,67, 38); break; // Power break;
  67. case 'H': irsend.sendRaw (S_fca,67, 38); break; // funcao;
  68. case 'I': irsend.sendRaw (S_vol,67, 38); break; // Volume - ;
  69. case 'J': irsend.sendRaw (S_volm,67, 38); break; // Volume +;
  70. case 'K': irsend.sendRaw (S_volm,67, 38); break; // anterior;
  71. case 'L': irsend.sendRaw (S_ava,67, 38); break; // avancar;
  72. case 'M': irsend.sendRaw (S_pla,67, 38); break; //play;
  73. case 'N': irsend.sendRaw (S_cim,67, 38); break; //cima;
  74. case 'O': irsend.sendRaw (S_bai,67, 38); break; //baixo;
  75.  
  76. //FITA DE LED;
  77. case 'm': irsend.sendNEC (0xFF02FD, 32); break; // Power;
  78. case 'n': irsend.sendNEC (0xFF3AC5, 32); break; // Aumentar Brilho;
  79. case 'o': irsend.sendNEC (0xFFBA45, 32); break; // Diminuir Brilho;
  80. case 'p': irsend.sendNEC (0xFF9A65, 32); break; // Vermelho;
  81. case 'q': irsend.sendNEC (0xFF1AE5, 32); break; // Verde;
  82. case 'r': irsend.sendNEC (0xFFA25D, 32); break; // Azul;
  83. case 's': irsend.sendNEC (0xFF22DD, 32); break; // Branco;
  84. case 't': irsend.sendNEC (0xFFE817, 32); break; // + Velocidade;
  85. case 'u': irsend.sendNEC (0xFFC837, 32); break; // - Velocidade;
  86. case 'v': irsend.sendNEC (0xFFF00F, 32); break; // Auto;
  87. case 'y': irsend.sendNEC (0xFFD02F, 32); break; // Flash;
  88. case 'x': irsend.sendNEC (0xFFE01F, 32); break; // Efeito 1;
  89. case 'w': irsend.sendNEC (0xFF609F, 32); break; // Efeito 2;
  90.  
  91. //LAMPADAS:
  92. //CANAL 1//
  93. case '1':digitalWrite(ch1, !digitalRead(ch1)); break; //Quarto;
  94. case '5':digitalWrite(ch2, !digitalRead(ch2)); break; //NULO;
  95. case '3':digitalWrite(ch3, !digitalRead(ch3)); break; //escada;
  96. case '4':digitalWrite(ch4, !digitalRead(ch4)); break; // Banheiro
  97. }
  98. delay(10);
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement