Advertisement
lucasx2016

Untitled

Oct 26th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.47 KB | None | 0 0
  1. #include <IRremote.h>
  2. #include <IRremoteInt.h>
  3. #include <SoftwareSerial.h>
  4. IRsend irsend;
  5. SoftwareSerial bluetooth (14,15); // 14tx 15 rx
  6.  
  7. const int RECV_PIN = 2;
  8. const int Rele = 8;
  9. IRrecv irrecv(RECV_PIN);
  10. decode_results results;
  11.  
  12. int led = 9;
  13. int ch1 = 3;
  14. int ch2 = 5;
  15. int ch3 = 6;
  16. int ch4 = 7;
  17. 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,};
  18. 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,};
  19. 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,};
  20. 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,};
  21. unsigned int S_ant[67]={4550,4350,600,1600,600,1600,650,500,600,500,600,500,650,450,650,1600,600,500,650,1550,650,1600,600,500,650,450,650,1600,600,500,600,1600,600,500,650,1600,600,1600,650,450,650,1600,600,1600,650,450,650,500,600,500,600,500,650,450,650,1600,600,500,600,500,600,1600,650,1600,650,1550,650,};
  22. 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,};
  23. 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,};
  24. 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,};
  25. 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,};
  26. //---------------------------------------------------------
  27. void setup()
  28. {
  29. Serial.begin(9600);
  30. bluetooth.begin(9600);// alguns (34800)
  31. pinMode(led,OUTPUT); //infravermelho;
  32. pinMode(ch1, OUTPUT);//Pino digital saída do Arduino(4-ch1);
  33. pinMode(ch2, OUTPUT);//Pino digital saída do Arduino(5-ch2);
  34. pinMode(ch3, OUTPUT);//Pino digital saída do Arduino(6-ch3);
  35. pinMode(ch4, OUTPUT);//Pino digital saída do Arduino(7-ch4);
  36.  
  37. pinMode(Rele,OUTPUT);
  38. irrecv.enableIRIn();
  39. }
  40. //---------------------------------------------------------
  41. void loop() {
  42.  
  43. if (irrecv.decode(&results))
  44. {
  45. Serial.println(results.value, HEX);
  46. if(results.value == 0xFF4AB5) // LIGA QUARTO//
  47. {
  48. digitalWrite(ch1, HIGH);
  49. }
  50. if(results.value == 0xFFC639) // DESLIGA QUARTO
  51. {
  52. digitalWrite(ch1, LOW);
  53. }
  54.  
  55. if(results.value == 0xFF46B9) // LIGA BANHEIRO//
  56. {
  57. digitalWrite(ch2, HIGH);
  58. }
  59. if(results.value == 0xFF8679) // DESLIGA BANHEIRO //
  60. {
  61. digitalWrite(ch2, LOW);
  62. }
  63.  
  64.  
  65. irrecv.resume();
  66. }
  67. if (Serial.available() > 0)
  68. {
  69. char valorlido = Serial.read();
  70.  
  71. switch(valorlido)
  72. {
  73. // controle Receptor ///
  74. case 'E': irsend.sendNEC (0xFF50AF, 32);break; // Power break;
  75. case 'F': irsend.sendNEC (0xFFB04F, 32);break; // Botao OK ;
  76. case 'P': irsend.sendNEC (0xFF8877, 32);break; // SETA PRA DIREITA ;
  77. case 'Q': irsend.sendNEC (0xFF08F7, 32);break; // SETA PRA ESQUERDA ;
  78. case 'R': irsend.sendNEC (0xFFD02F, 32);break; // SETA PRA CIMA ;
  79. case 'S': irsend.sendNEC (0xFF708F, 32);break; // SETA PRA BAIXO ;
  80. case 'T': irsend.sendNEC (0xFF7887, 32);break; // EXIT ;
  81. case 'U': irsend.sendNEC (0xFF6C93, 32);break; // SLEEP ;
  82. case 'V': irsend.sendNEC (0xFF58A7, 32);break; // MENU ;
  83. case 'W': irsend.sendNEC (0xFFEA15, 32);break; // FAVORITO ;
  84. case 'B': irsend.sendNEC (0xFFCC33, 32);break; // MUDO ;
  85.  
  86. //Controle da tv //
  87. case 'a': irsend.sendNEC (0x2FD48B7, 32);break; // Power break;
  88. case 'b': irsend.sendNEC (0x2FDF00F, 32);break; // Input;
  89. case 'c': irsend.sendNEC (0x2FD01FE, 32);break; // Menu;
  90. case 'd': irsend.sendNEC (0x2FD41BE, 32);break; // Tecla Cima;
  91. case 'e': irsend.sendNEC (0x2FDC13E, 32);break; // Tecla Baixo;
  92. case 'f': irsend.sendNEC (0x2FDB847, 32);break; // Tecla Esquerda;
  93. case 'g': irsend.sendNEC (0x2FD9867, 32);break; // Tecla Direita;
  94. case 'h': irsend.sendNEC (0x2FD58A7, 32);break; // Volume +;
  95. case 'i': irsend.sendNEC (0x2FD7887, 32);break; // Volume -;
  96. case 'j': irsend.sendNEC (0x2FDD827, 32);break; // Canal +;
  97. case 'k': irsend.sendNEC (0x2FDF807, 32);break; // Canal -;
  98. case 'l': irsend.sendNEC (0x2FD08F7, 32);break; // Mute;
  99. case 'z': irsend.sendNEC (0x2FD916E, 32);break; // Enter;
  100. case 'A': irsend.sendNEC (0x2FD20DF, 32);break; // Sbt:
  101. case 'C': irsend.sendNEC (0x2FDE01F, 32);break; // Record:
  102. case 'D': irsend.sendNEC (0x2FDA857, 32);break; // Sleep:
  103. case 'X': irsend.sendNEC (0x2FD54AB, 32);break; // Netflix:
  104.  
  105. //Controle Home;
  106. case 'G': irsend.sendRaw (S_pwr,67, 38);break; // Power break;
  107. case 'H': irsend.sendRaw (S_fca,67, 38);break; // funcao;
  108. case 'I': irsend.sendRaw (S_vol,67, 38);break; // Volume - ;
  109. case 'J': irsend.sendRaw (S_volm,67, 38);break; // Volume +;
  110. case 'K': irsend.sendRaw (S_ant,67, 38);break; // anterior;
  111. case 'L': irsend.sendRaw (S_ava,67, 38);break; // avancar;
  112. case 'M': irsend.sendRaw (S_pla,67, 38);break; //play;
  113. case 'N': irsend.sendRaw (S_cim,67, 38);break; //cima;
  114. case 'O': irsend.sendRaw (S_bai,67, 38);break;//baixo;
  115.  
  116.  
  117. //LAMPADAS:
  118.  
  119. //CANAL 1//
  120. case '1':digitalWrite(ch1, !digitalRead(ch1));break;//Quarto;
  121. case '5':digitalWrite(ch2, !digitalRead(ch2));break;//NULO;
  122. case '3':digitalWrite(ch3, !digitalRead(ch3));break;//escada;
  123. case '4':digitalWrite(ch4, !digitalRead(ch4));break; // Banheiro
  124. }
  125. irrecv.enableIRIn();
  126.  
  127. }
  128.  
  129. delay(10);
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement