Advertisement
lucasx2016

Ajuda

Feb 8th, 2017
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.97 KB | None | 0 0
  1. /*PROJETO AUTOMAÇÃO 1.5 (QUARTO)
  2. Ajuda a desenvolver e dicas no codigo
  3. Rui Viana lab de garagem , Marcos Lab de garabem e
  4. Romario de Jesus Santana lab de garagem
  5. sinceros agradecimentos a todos*/
  6.  
  7.  
  8. //CONTROLE REMOTO
  9. #include <IRremote.h>
  10. #include <SPI.h>
  11. #include <Ethernet.h> //W5100
  12. #define RECV_PIN 2
  13. IRsend irsend;
  14. //define receptor IR
  15. IRrecv irrecv(RECV_PIN);
  16. decode_results results;
  17.  
  18. bool rele4=true, rele5=true;//variaveis para estado do rele
  19.  
  20. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  21. IPAddress ip(192, 168, 1, 177);
  22.  
  23. EthernetServer server(80);
  24.  
  25. //RELES
  26. #define pino_rele4 4 // Luz Quarto
  27. #define pino_rele5 5 // Luz do banheiro
  28. /// Home Teather//
  29. 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,};
  30. 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,};
  31. 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,};
  32. 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,};
  33. 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,};
  34. 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,};
  35. 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,};
  36. 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,};
  37. 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,};
  38. /// ar condicionado
  39. unsigned int des_ar[59] = {3208, 9548, 608, 1444, 608, 412, 604, 408, 604, 408, 604, 1448, 604, 432, 604, 412, 604, 408, 608, 1420, 608, 1420, 604, 432, 584, 428, 608, 408, 604, 412, 604, 408, 608, 428, 584, 432, 580, 432, 580, 432, 584, 432, 580, 432, 584, 1444, 580, 432, 580, 1448, 492, 520, 524, 492, 604, 432, 584, 1444, 580,};
  40. unsigned int modo_ar[59] = {3168, 9640, 524, 1500, 576, 444, 548, 464, 548, 464, 552, 1476, 548, 488, 524, 488, 528, 488, 524, 488, 496, 516, 500, 516, 520, 496, 520, 1528, 524, 492, 520, 1508, 520, 492, 520, 496, 520, 492, 520, 1528, 500, 1556, 496, 516, 496, 1528, 500, 516, 572, 440, 496, 516, 500, 516, 496, 516, 552, 1476, 520,};
  41. unsigned int velocidade_ar[61] = {368, 43108, 3152, 9604, 580, 1472, 524, 492, 552, 460, 552, 460, 556, 1472, 552, 464, 576, 436, 576, 436, 580, 1448, 580, 456, 556, 1472, 556, 456, 580, 436, 576, 436, 608, 408, 604, 432, 580, 1448, 604, 432, 584, 1444, 580, 1448, 580, 436, 600, 1448, 580, 436, 572, 440, 572, 1456, 572, 468, 544, 468, 544, 1484, 544,};
  42. unsigned int aumenta_ar[59] = {3196, 9612, 572, 1452, 524, 516, 500, 512, 500, 516, 496, 1532, 520, 496, 520, 516, 496, 516, 572, 440, 576, 440, 572, 440, 576, 440, 548, 1476, 576, 436, 576, 464, 500, 516, 496, 1528, 500, 516, 496, 516, 576, 1456, 520, 492, 520, 1528, 500, 516, 496, 516, 500, 512, 576, 1452, 572, 440, 520, 1532, 500,};
  43. unsigned int diminui_ar[59] = {3184, 9624, 552, 1504, 524, 488, 584, 428, 584, 432, 584, 1468, 604, 436, 584, 428, 584, 432, 584, 428, 584, 428, 584, 432, 584, 428, 584, 1468, 584, 428, 584, 432, 584, 428, 540, 1488, 608, 432, 584, 428, 496, 516, 500, 516, 496, 1556, 584, 428, 584, 428, 500, 516, 596, 1432, 608, 428, 500, 516, 608,};
  44. unsigned int lig_ar[59] = {3124, 9636, 552, 1500, 524, 492, 576, 436, 576, 436, 552, 1500, 528, 516, 496, 516, 500, 512, 580, 436, 544, 468, 572, 444, 572, 440, 552, 460, 580, 436, 576, 1448, 524, 496, 520, 496, 520, 492, 520, 1528, 500, 1528, 500, 512, 500, 1528, 500, 512, 552, 1504, 576, 1448, 580, 436, 520, 1512, 520, 492, 520,};
  45.  
  46. void setup() {
  47. pinMode(pino_rele4, OUTPUT); // Quarto
  48. pinMode(pino_rele5, OUTPUT); // banheiro
  49. //Desliga os reles
  50. digitalWrite(pino_rele4, HIGH); // Quarto
  51. digitalWrite(pino_rele5, HIGH); // banheiro
  52. Ethernet.begin(mac, ip);
  53. server.begin();
  54. //Controle remoto mega pin 9
  55. pinMode(9, OUTPUT);
  56. digitalWrite(9, LOW);
  57. irrecv.enableIRIn();
  58. }
  59.  
  60. void loop() {
  61. EthernetClient client = server.available();
  62. if (client) {
  63. String vars;
  64. byte acao = 0;
  65. boolean currentLineIsBlank = true;
  66. while (client.connected()) {
  67. if (client.available()) {
  68. char c = client.read();
  69. vars.concat(c);
  70. //Página Html//
  71. if (c == '\n') {
  72. client.println(F("HTTP/1.1 200 OK"));
  73. client.println(F("Content-Type: text/html"));
  74. client.println();
  75. client.println(F("<!doctype html>"));
  76. client.println(F("<head>"));
  77. client.println(F("<meta charset=\"utf-8\">"));
  78. client.println(F("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\""));
  79. client.println(F("<title>Automação meu QUARTO</title>"));
  80. client.println(F("<meta name=\"viewport\" content=\"width=320\">"));
  81. client.println(F("<meta name=\"viewport\" content=\"width=device-width\">"));
  82. client.println(F("<meta charset=\"utf-8\">"));
  83. client.println(F("<meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable=no\">"));
  84. client.println(F("</head>"));
  85. client.println(F("<body>"));
  86. client.println(F("<center>"));
  87. client.println(F("<meta charset=\"utf-8\">"));
  88. client.println(F("<font size=\"5\" face=\"verdana\" color=\"green\">AUTOMAÇÃO</font>"));
  89. client.println(F("<font size=\"5\" face=\"verdana\" color=\"blue\"> QUARTO</font><br />"));
  90. client.println(F("</center>"));
  91. ///REles
  92. client.println(F("<form action=\"/quarto\" method=\"get\">"));
  93. client.println(F("<button type=submit style=\"width:200px;\">On-Off Quarto</button> "));
  94. client.println(F("</form> <br />"));
  95. client.println(F("<form action=\"/banheiro\" method=\"get\">"));
  96. client.println(F("<button type=submit style=\"width:200px;\">On-Off Banheiro</button> "));
  97. client.println(F("</form> <br />"));
  98. //// receptor
  99. client.println(F("<font size=\"5\" face=\"verdana\" color=\"green\">Controle Receptor</font>"));
  100. client.println(F("<form action=\"/receptor\" method=\"get\">"));
  101. client.println(F("<button type=submit style=\"width:200px;\">On Off Receptor</button> "));
  102. client.println(F("</form> <br />"));
  103. client.println(F("<form action=\"/cima\" method=\"get\">"));
  104. client.println(F("<button type=submit style=\"width:200px;\">Cima </button> "));
  105. client.println(F("</form> <br />"));
  106. client.println(F("<form action=\"/setadireita\" method=\"get\">"));
  107. client.println(F("<button type=submit style=\"width:200px;\">Direita </button> "));
  108. client.println(F("</form> <br />"));
  109. client.println(F("<form action=\"/setaesquerda\" method=\"get\">"));
  110. client.println(F("<button type=submit style=\"width:200px;\">Esquerda </button> "));
  111. client.println(F("</form> <br />"));
  112. client.println(F("<form action=\"/ok\" method=\"get\">"));
  113. client.println(F("<button type=submit style=\"width:200px;\">oK </button> "));
  114. client.println(F("</form> <br />"));
  115. client.println(F("<form action=\"/baixo\" method=\"get\">"));
  116. client.println(F("<button type=submit style=\"width:200px;\">Baixo </button> "));
  117. client.println(F("</form> <br />"));
  118. client.println(F("<form action=\"/cenatv\" method=\"get\">"));
  119. client.println(F("<button type=submit style=\"width:200px;\">Cena - TV </button> "));
  120. client.println(F("</form> <br />"));
  121. client.println(F("<form action=\"/exitre\" method=\"get\">"));
  122. client.println(F("<button type=submit style=\"width:200px;\">Exit</button> "));
  123. client.println(F("</form> <br />"));
  124. client.println(F("<form action=\"/sleep\" method=\"get\">"));
  125. client.println(F("<button type=submit style=\"width:200px;\">Temporizador</button> "));
  126. client.println(F("</form> <br />"));
  127. client.println(F("<form action=\"/recmenu\" method=\"get\">"));
  128. client.println(F("<button type=submit style=\"width:200px;\">Menu</button> "));
  129. client.println(F("</form> <br />"));
  130. client.println(F("<form action=\"/favorito\" method=\"get\">"));
  131. client.println(F("<button type=submit style=\"width:200px;\">Favorito</button> "));
  132. client.println(F("</form> <br />"));
  133. client.println(F("<form action=\"/1\" method=\"get\">"));
  134. client.println(F("<button type=submit style=\"width:200px;\">1</button> "));
  135. client.println(F("</form> <br />"));
  136. client.println(F("<form action=\"/2\" method=\"get\">"));
  137. client.println(F("<button type=submit style=\"width:200px;\">2</button> "));
  138. client.println(F("</form> <br />"));
  139. client.println(F("<form action=\"/3\" method=\"get\">"));
  140. client.println(F("<button type=submit style=\"width:200px;\">3</button> "));
  141. client.println(F("</form> <br />"));
  142. client.println(F("<form action=\"/4\" method=\"get\">"));
  143. client.println(F("<button type=submit style=\"width:200px;\">4</button> "));
  144. client.println(F("</form> <br />"));
  145. client.println(F("<form action=\"/5\" method=\"get\">"));
  146. client.println(F("<button type=submit style=\"width:200px;\">5</button> "));
  147. client.println(F("</form> <br />"));
  148. client.println(F("<form action=\"/6\" method=\"get\">"));
  149. client.println(F("<button type=submit style=\"width:200px;\">6</button> "));
  150. client.println(F("</form> <br />"));
  151. client.println(F("<form action=\"/7\" method=\"get\">"));
  152. client.println(F("<button type=submit style=\"width:200px;\">7</button> "));
  153. client.println(F("</form> <br />"));
  154. client.println(F("<form action=\"/8\" method=\"get\">"));
  155. client.println(F("<button type=submit style=\"width:200px;\">8</button> "));
  156. client.println(F("</form> <br />"));
  157. client.println(F("<form action=\"/9\" method=\"get\">"));
  158. client.println(F("<button type=submit style=\"width:200px;\">9</button> "));
  159. client.println(F("</form> <br />"));
  160. client.println(F("<form action=\"/0\" method=\"get\">"));
  161. client.println(F("<button type=submit style=\"width:200px;\">0</button> "));
  162. client.println(F("</form> <br />"));
  163. ////controletv
  164. client.println(F("<font size=\"5\" face=\"verdana\" color=\"green\">Controle Tv</font>"));
  165. client.println(F("<form action=\"/tv\" method=\"get\">"));
  166. client.println(F("<button type=submit style=\"width:200px;\">On-Off TV</button> "));
  167. client.println(F("</form> <br />"));
  168. client.println(F("<form action=\"/input\" method=\"get\">"));
  169. client.println(F("<button type=submit style=\"width:200px;\">Input</button> "));
  170. client.println(F("</form> <br />"));
  171. client.println(F("<form action=\"/setacima\" method=\"get\">"));
  172. client.println(F("<button type=submit style=\"width:200px;\">Cima </button> "));
  173. client.println(F("</form> <br />"));
  174. client.println(F("<form action=\"/setabaixo\" method=\"get\">"));
  175. client.println(F("<button type=submit style=\"width:200px;\">Baixo</button> "));
  176. client.println(F("</form> <br />"));
  177. client.println(F("<form action=\"/esquerdatv\" method=\"get\">"));
  178. client.println(F("<button type=submit style=\"width:200px;\">Esquerda </button> "));
  179. client.println(F("</form> <br />"));
  180. client.println(F("<form action=\"/direitatv\" method=\"get\">"));
  181. client.println(F("<button type=submit style=\"width:200px;\">Direita </button> "));
  182. client.println(F("</form> <br />"));
  183. client.println(F("<form action=\"/volume+\" method=\"get\">"));
  184. client.println(F("<button type=submit style=\"width:200px;\">Vol +</button> "));
  185. client.println(F("</form> <br />"));
  186. client.println(F("<form action=\"/volume-\" method=\"get\">"));
  187. client.println(F("<button type=submit style=\"width:200px;\">Vol -</button> "));
  188. client.println(F("</form> <br />"));;
  189. client.println(F("<form action=\"/exittv\" method=\"get\">"));
  190. client.println(F("<button type=submit style=\"width:200px;\">Exit TV</button> "));
  191. client.println(F("</form> <br />"));
  192. client.println(F("<form action=\"/voltar\" method=\"get\">"));
  193. client.println(F("<button type=submit style=\"width:200px;\">Voltar</button> "));
  194. client.println(F("</form> <br />"));
  195. client.println(F("<form action=\"/mute\" method=\"get\">"));
  196. client.println(F("<button type=submit style=\"width:200px;\">Mudo</button> "));
  197. client.println(F("</form> <br />"));
  198. client.println(F("<form action=\"/enter\" method=\"get\">"));
  199. client.println(F("<button type=submit style=\"width:200px;\">Enter</button> "));
  200. client.println(F("</form> <br />"));
  201. client.println(F("<form action=\"/temp\" method=\"get\">"));
  202. client.println(F("<button type=submit style=\"width:200px;\">Temporizar TV</button> "));
  203. client.println(F("</form> <br />"));
  204. client.println(F("<form action=\"/netflix\" method=\"get\">"));
  205. client.println(F("<button type=submit style=\"width:200px;\">Netflix</button> "));
  206. client.println(F("</form> <br />"));
  207. client.println(F("<form action=\"/menutv\" method=\"get\">"));
  208. client.println(F("<button type=submit style=\"width:200px;\">Menu TV</button> "));
  209. client.println(F("</form> <br />"));
  210. /// CONTROLE HOME
  211. client.println(F("<font size=\"5\" face=\"verdana\" color=\"green\">Controle Home</font>"));
  212. client.println(F("<form action=\"/home\" method=\"get\">"));
  213. client.println(F("<button type=submit style=\"width:200px;\">On Off Home</button> "));
  214. client.println(F("</form> <br />"));
  215. client.println(F("<form action=\"/funcao\" method=\"get\">"));
  216. client.println(F("<button type=submit style=\"width:200px;\">Função</button> "));
  217. client.println(F("</form> <br />"));
  218. client.println(F("<form action=\"/volmenoshome\" method=\"get\">"));
  219. client.println(F("<button type=submit style=\"width:200px;\">Vol -</button> "));
  220. client.println(F("</form> <br />"));
  221. client.println(F("<form action=\"/volmaishome\" method=\"get\">"));
  222. client.println(F("<button type=submit style=\"width:200px;\">Vol +</button> "));
  223. client.println(F("</form> <br />"));
  224. client.println(F("<form action=\"/anterior\" method=\"get\">"));
  225. client.println(F("<button type=submit style=\"width:200px;\">Anterior</button> "));
  226. client.println(F("</form> <br />"));
  227. client.println(F("<form action=\"/avancar\" method=\"get\">"));
  228. client.println(F("<button type=submit style=\"width:200px;\">Avançar TV</button> "));
  229. client.println(F("</form> <br />"));
  230. client.println(F("<form action=\"/play\" method=\"get\">"));
  231. client.println(F("<button type=submit style=\"width:200px;\">Play</button> "));
  232. client.println(F("</form> <br />"));
  233. client.println(F("<form action=\"/btncim\" method=\"get\">"));
  234. client.println(F("<button type=submit style=\"width:200px;\">Cima</button> "));
  235. client.println(F("</form> <br />"));
  236. /// apartir daqui nao funciona comando
  237. client.println(F("<form action=\"/btnbai\" method=\"get\">"));
  238. client.println(F("<button type=submit style=\"width:200px;\">Baixo</button> "));
  239. client.println(F("</form> <br />"));
  240. ///Controle ar Condicionado
  241. client.println(F("<font size=\"5\" face=\"verdana\" color=\"green\">Controle Ar Condicionado</font>"));
  242. client.println(F("<form action=\"/ligarar\" method=\"get\">"));
  243. client.println(F("<button type=submit style=\"width:200px;\">On Ar</button> "));
  244. client.println(F("</form> <br />"));
  245. client.println(F("<form action=\"/desliga_ar\" method=\"get\">"));
  246. client.println(F("<button type=submit style=\"width:200px;\">Off Ar </button> "));
  247. client.println(F("</form> <br />"));
  248. client.println(F("<form action=\"/modo\" method=\"get\">"));
  249. client.println(F("<button type=submit style=\"width:200px;\">Modo</button> "));
  250. client.println(F("</form> <br />"));
  251. client.println(F("<form action=\"/velocidade\" method=\"get\">"));
  252. client.println(F("<button type=submit style=\"width:200px;\">Velocidade</button> "));
  253. client.println(F("</form> <br />"));
  254. client.println(F("<form action=\"/menosar\" method=\"get\">"));
  255. client.println(F("<button type=submit style=\"width:200px;\">Ar -</button> "));
  256. client.println(F("</form> <br />"));
  257. client.println(F("<form action=\"/maisar\" method=\"get\">"));
  258. client.println(F("<button type=submit style=\"width:200px;\">Ar + </button> "));
  259. client.println(F("</form> <br />"));
  260. ///fita de led
  261. client.println(F("<font size=\"5\" face=\"verdana\" color=\"green\">Fita de Led</font>"));
  262. client.println(F("<form action=\"/led\" method=\"get\">"));
  263. client.println(F("<button type=submit style=\"width:200px;\">Liga Led </button> "));
  264. client.println(F("</form> <br />"));
  265. client.println(F("<form action=\"/aumenta\" method=\"get\">"));
  266. client.println(F("<button type=submit style=\"width:200px;\">Aumenta </button> "));
  267. client.println(F("</form> <br />"));
  268. client.println(F("<form action=\"/diminui\" method=\"get\">"));
  269. client.println(F("<button type=submit style=\"width:200px;\">Diminui </button> "));
  270. client.println(F("</form> <br />"));
  271. client.println(F("<form action=\"/azul\" method=\"get\">"));
  272. client.println(F("<button type=submit style=\"width:200px;\">Azul </button> "));
  273. client.println(F("</form> <br />"));
  274. client.println(F("<form action=\"/vermelho\" method=\"get\">"));
  275. client.println(F("<button type=submit style=\"width:200px;\">Vermelho </button> "));
  276. client.println(F("</form> <br />"));
  277. client.println(F("<form action=\"/verde\" method=\"get\">"));
  278. client.println(F("<button type=submit style=\"width:200px;\">Verde </button> "));
  279. client.println(F("</form> <br />"));
  280. client.println(F("<form action=\"/branco\" method=\"get\">"));
  281. client.println(F("<button type=submit style=\"width:200px;\">Branco </button> "));
  282. client.println(F("</form> <br />"));
  283. client.println(F("<form action=\"/flash\" method=\"get\">"));
  284. client.println(F("<button type=submit style=\"width:200px;\">Flash </button> "));
  285. client.println(F("</form> <br />"));
  286. client.println(F("<form action=\"/efei1\" method=\"get\">"));
  287. client.println(F("<button type=submit style=\"width:200px;\">Efeito 1 </button> "));
  288. client.println(F("</form> <br />"));
  289. client.println(F("<form action=\"/efei2\" method=\"get\">"));
  290. client.println(F("<button type=submit style=\"width:200px;\">Efeito 2 </button> "));
  291. client.println(F("</form> <br />"));
  292. client.println(F("<form action=\"/efei3\" method=\"get\">"));
  293. client.println(F("<button type=submit style=\"width:200px;\">Efeito 3 </button> "));
  294. client.println(F("</form> <br />"));
  295. client.println(F("<form action=\"/efei4\" method=\"get\">"));
  296. client.println(F("<button type=submit style=\"width:200px;\">Efeito 4 </button> "));
  297. client.println(F("</form> <br />"));
  298. client.println(F("<form action=\"/slow\" method=\"get\">"));
  299. client.println(F("<button type=submit style=\"width:200px;\">Slow </button> "));
  300. client.println(F("</form> <br />"));
  301. client.println(F("<form action=\"/quick\" method=\"get\">"));
  302. client.println(F("<button type=submit style=\"width:200px;\">Quick</button> "));
  303. client.println(F("</form> <br />"));
  304. client.println(F(""));
  305. client.println(F("</center>"));
  306. client.println(F("</body>"));
  307. client.println(F("</html>"));
  308. break;
  309. }//final if \n
  310. }//final client.avaliable
  311.  
  312. //AQUI ACONTECEM AS COMPARACOES(Receptor)
  313. /// if (vars.endsWith(F("/ligarec"))) acao = 2;
  314. if (vars.endsWith(F("/cenatv"))) acao = 3;
  315. else if (vars.endsWith(F("/ok"))) acao = 4;
  316. else if (vars.endsWith(F("/setadireita"))) acao = 5;
  317. else if (vars.endsWith(F("/setaesquerda"))) acao = 6;
  318. else if (vars.endsWith(F("/cima"))) acao = 7;
  319. else if (vars.endsWith(F("/baixo"))) acao = 8;
  320. else if (vars.endsWith(F("/exitre"))) acao = 9;
  321. else if (vars.endsWith(F("/sleep"))) acao=10;
  322. else if (vars.endsWith(F("/recmenu"))) acao=11;
  323. else if (vars.endsWith(F("/favorito"))) acao=12;
  324. else if (vars.endsWith(F("/1"))) acao=13;
  325. else if (vars.endsWith(F("/2"))) acao=14;
  326. else if (vars.endsWith(F("/3"))) acao=15;
  327. else if (vars.endsWith(F("/4"))) acao=16;
  328. else if (vars.endsWith(F("/5"))) acao=17;
  329. else if (vars.endsWith(F("/6"))) acao=18;
  330. else if (vars.endsWith(F("/7"))) acao=19;
  331. else if (vars.endsWith(F("/8"))) acao = 20;
  332. else if (vars.endsWith(F("/9"))) acao = 21;
  333. else if (vars.endsWith(F("/0"))) acao = 22;
  334. else if (vars.endsWith(F("/receptor"))) acao = 55;
  335. /// Rele
  336. else if (vars.endsWith(F("/quarto"))) acao = 23;
  337. else if (vars.endsWith(F("/banheiro"))) acao = 24;
  338. /// Controle TV
  339. else if (vars.endsWith(F("/tv"))) acao = 25;
  340. else if (vars.endsWith(F("/input"))) acao = 26;
  341. else if (vars.endsWith(F("/menutv"))) acao = 27;
  342. else if (vars.endsWith(F("/setacima"))) acao = 28;
  343. else if (vars.endsWith(F("/setabaixo"))) acao = 29;
  344. else if (vars.endsWith(F("/esquerdatv"))) acao = 30;
  345. else if (vars.endsWith(F("/direitatv"))) acao = 31;
  346. else if (vars.endsWith(F("/volume+"))) acao = 32;
  347. else if (vars.endsWith(F("/volume-"))) acao = 33;
  348. else if (vars.endsWith(F("/exittv"))) acao = 34;
  349. else if (vars.endsWith(F("/voltar"))) acao = 35;
  350. else if (vars.endsWith(F("/mutetv"))) acao = 36;
  351. else if (vars.endsWith(F("/temp"))) acao = 37;
  352. else if (vars.endsWith(F("/netflix"))) acao = 38;
  353. else if (vars.endsWith(F("/enter"))) acao = 39;
  354. /// Controle HOME
  355. else if (vars.endsWith(F("/home"))) acao = 40;
  356. else if (vars.endsWith(F("/funcao"))) acao = 41;
  357. else if (vars.endsWith(F("/volmenoshome"))) acao = 42;
  358. else if (vars.endsWith(F("/volmaishome"))) acao = 43;
  359. else if (vars.endsWith(F("/anterio"))) acao = 44;
  360. else if (vars.endsWith(F("/avancar"))) acao = 45;
  361. else if (vars.endsWith(F("/play"))) acao = 46;
  362. else if (vars.endsWith(F("/btncim"))) acao = 47;
  363. /// apartir daqui nao funciona comando
  364. else if (vars.endsWith(F("/btnbai"))) acao = 48;
  365. //Controle Ar
  366. else if (vars.endsWith(F("/ligarar"))) acao = 49;
  367. else if (vars.endsWith(F("/desliga_ar"))) acao = 50;
  368. else if (vars.endsWith(F("/modo"))) acao = 51;
  369. else if (vars.endsWith(F("/velocidade"))) acao = 52;
  370. else if (vars.endsWith(F("/maisar"))) acao = 53;
  371. else if (vars.endsWith(F("/menosar"))) acao = 54;
  372. /// fita led
  373. else if (vars.endsWith(F("/led"))) acao = 56;
  374. else if (vars.endsWith(F("/aumenta"))) acao = 57;
  375. else if (vars.endsWith(F("/diminui"))) acao = 58;
  376. else if (vars.endsWith(F("/azul"))) acao = 59;
  377. else if (vars.endsWith(F("/vermelho"))) acao = 60;
  378. else if (vars.endsWith(F("/verde"))) acao = 61;
  379. else if (vars.endsWith(F("/branco"))) acao = 62;
  380. else if (vars.endsWith(F("/flash"))) acao = 63;
  381. else if (vars.endsWith(F("/efei1"))) acao = 64;
  382. else if (vars.endsWith(F("/efei2"))) acao = 65;
  383. else if (vars.endsWith(F("/efei3"))) acao = 66;
  384. else if (vars.endsWith(F("/efei4"))) acao = 67;
  385. else if (vars.endsWith(F("/slow"))) acao = 68;
  386. else if (vars.endsWith(F("/quick"))) acao = 69;
  387.  
  388.  
  389.  
  390.  
  391.  
  392. if (acao == 3) { //liga , DESLIGANDO A TV
  393. //Ligar receptor
  394. irsend.sendNEC(0xFF50AF, 32);
  395. delay(2000);
  396. //ligar tv
  397. irsend.sendNEC(0x2FD48B7, 32);
  398. acao = 0;
  399. }
  400. if (acao == 4) { //Ok
  401.  
  402. irsend.sendNEC(0xFFB04F, 32);
  403. acao = 0;
  404. }
  405. if (acao == 5) { //SetaDiretia
  406.  
  407. irsend.sendNEC(0xFF8877, 32);
  408. acao = 0;
  409. }
  410. if (acao == 6) { //seta esquerda
  411.  
  412. irsend.sendNEC(0xFF08F7, 32);
  413. acao = 0;
  414. }
  415. if (acao == 7) { //Seta cima
  416.  
  417. irsend.sendNEC(0xFFD02F, 32);
  418. acao = 0;
  419. }
  420. if (acao == 8) { //Seta baixo
  421.  
  422. irsend.sendNEC(0xFF708F, 32);
  423. acao = 0;
  424. }
  425.  
  426.  
  427. if (acao == 9){ //exit
  428.  
  429. irsend.sendNEC (0xFF7887, 32);
  430. acao = 0;
  431. }
  432. if (acao == 10){ //Sleep
  433.  
  434. irsend.sendNEC(0xFF6C93, 32);
  435. acao = 0;
  436. }
  437. if (acao == 11){ //Menu
  438.  
  439. irsend.sendNEC(0xFF58A7, 32);
  440. acao = 0;
  441. }
  442. if (acao == 12){ //Favorito
  443.  
  444. irsend.sendNEC(0xFFEA15, 32);
  445. acao = 0;
  446. }
  447.  
  448. if (acao == 14){ //2
  449.  
  450. irsend.sendNEC(0xFF40BF, 32);
  451. acao = 0;
  452. }
  453. if (acao == 15){ //3
  454.  
  455. irsend.sendNEC(0xFFC03F, 32);
  456. acao = 0;
  457. }
  458. if (acao == 16){ //4
  459.  
  460. irsend.sendNEC(0xFF20DF, 32);
  461. acao = 0;
  462. }
  463.  
  464. if (acao == 17){ //5
  465.  
  466. irsend.sendNEC(0xFFA05F, 32);
  467. acao = 0;
  468. }
  469. if (acao == 18){ //6
  470.  
  471. irsend.sendNEC(0xFF609F, 32);
  472. acao = 0;
  473. }
  474. if (acao == 19){ //7
  475.  
  476. irsend.sendNEC(0xFFE01F, 32);
  477. acao = 0;
  478.  
  479. }
  480.  
  481. if (acao == 20){ //8
  482.  
  483. irsend.sendNEC (0xFF10EF, 32);
  484. acao = 0;
  485. }
  486. if (acao == 21){ //9
  487.  
  488. irsend.sendNEC(0xFF906F, 32);
  489. acao = 0;
  490. }
  491. if (acao == 22){ //0
  492.  
  493. irsend.sendNEC(0xFF00FF, 32);
  494. acao = 0;
  495. }
  496.  
  497. if (acao == 55) { //LIGANDO Receptor
  498. //Ligar receptor
  499. irsend.sendNEC(0xFF50AF, 32);
  500. }
  501. /// Reles
  502. if (acao == 24) { //Banheiro
  503. rele5 = !rele5;
  504. digitalWrite(pino_rele5, rele5);
  505. acao = 0;
  506. }
  507. if (acao == 23) { //Quarto
  508. rele4 = !rele4;
  509. digitalWrite(pino_rele4, rele4);
  510. acao = 0;
  511. }
  512. //acao tv
  513. if (acao == 25){ //ligar tv
  514.  
  515. irsend.sendNEC(0x2FD48B7, 32);
  516. acao = 0;
  517. }
  518. if (acao == 26){ //input
  519.  
  520. irsend.sendNEC(0x2FDF00F, 32);
  521. acao = 0;
  522. }
  523. if (acao == 27){ //menu
  524.  
  525. irsend.sendNEC(0x2FD01FE, 32);
  526. acao = 0;
  527. }
  528. if (acao == 28){ //Cima
  529.  
  530. irsend.sendNEC(0x2FD41BE, 32);
  531. acao = 0;
  532. }
  533. if (acao == 29){ //baixo
  534.  
  535. irsend.sendNEC(0x2FDC13E, 32);
  536. acao = 0;
  537. }
  538. if (acao == 30){ //Esquerda
  539.  
  540. irsend.sendNEC(0x2FDB847, 32);
  541. acao = 0;
  542. }
  543. if (acao == 31){ //Direita
  544.  
  545. irsend.sendNEC(0x2FD9867, 32);
  546. acao = 0;
  547. }
  548. if (acao == 32){ //Vol +
  549.  
  550. irsend.sendNEC(0x2FD58A7, 32);
  551. acao = 0;
  552. }
  553. if (acao == 33){ //vol -
  554.  
  555. irsend.sendNEC(0x2FD7887, 32);
  556. acao = 0;
  557. }
  558. if (acao == 34){ //Exit
  559.  
  560. irsend.sendNEC(0x2FD1AE5, 32);
  561. acao = 0;
  562. }
  563. if (acao == 35){ //Voltar
  564.  
  565. irsend.sendNEC(0xFF00FF, 32);
  566. acao = 0;
  567. }
  568. if (acao == 36){ //mute
  569.  
  570. irsend.sendNEC(0x2FD08F7, 32);
  571. acao = 0;
  572. }
  573. if (acao == 37){ //sleep
  574.  
  575. irsend.sendNEC(0x2FDA857, 32);
  576. acao = 0;
  577. }
  578. if (acao == 38){ //netflix
  579.  
  580. irsend.sendNEC(0x2FD54AB, 32);
  581. acao = 0;
  582. }
  583. if (acao == 39){ //enter
  584.  
  585. irsend.sendNEC(0x2FD916E, 32);
  586. acao = 0;
  587. }
  588. /// Home
  589. if (acao == 40){ //ligar
  590.  
  591. irsend.sendRaw(S_pwr, 67, 38);
  592. acao = 0;
  593. }
  594. if (acao == 41){ //funçao
  595.  
  596. irsend.sendRaw(S_fca, 67, 38);
  597. acao = 0;
  598. }
  599. if (acao == 42){ //vol -
  600.  
  601. irsend.sendRaw(S_vol, 67, 38);
  602. acao = 0;
  603. }
  604. if (acao == 43){ //vol +
  605.  
  606. irsend.sendRaw(S_volm, 67, 38);
  607. acao = 0;
  608. }
  609. if (acao == 44){ //anterior
  610.  
  611. irsend.sendRaw(S_ant, 67, 38);
  612. acao = 0;
  613. }
  614. if (acao == 45){ //avançar
  615.  
  616. irsend.sendRaw(S_ava, 67, 38);
  617. acao = 0;
  618. }
  619. if (acao == 46){ //play
  620.  
  621. irsend.sendRaw(S_pla, 67, 38);
  622. acao = 0;
  623. }
  624. if (acao == 47){ //cima
  625.  
  626. irsend.sendRaw(S_cim, 67, 38);
  627. acao = 0;
  628. }
  629.  
  630. /// apartir daqui nao funciona comando
  631. if (acao == 48){ //baixo
  632.  
  633. irsend.sendRaw(S_bai, 67, 38);
  634. acao = 0;
  635. }
  636. //Ar condicionado
  637. if (acao == 49){ //ligar
  638.  
  639. irsend.sendRaw(lig_ar, 59, 38);
  640. acao = 0;
  641. }
  642. if (acao == 50){ //desligar
  643.  
  644. irsend.sendRaw(des_ar, 59, 38);
  645. acao = 0;
  646. }
  647. if (acao == 51){ //modo
  648.  
  649. irsend.sendRaw(modo_ar, 59, 38);
  650. acao = 0;
  651. }
  652. if (acao == 52){ //velocidade
  653.  
  654. irsend.sendRaw(velocidade_ar, 61, 38);
  655. acao = 0;
  656. }
  657. if (acao == 53){ //mais Ar
  658.  
  659. irsend.sendRaw(aumenta_ar, 59, 38);
  660. acao = 0;
  661. }
  662. if (acao == 54){ //menos ar
  663.  
  664. irsend.sendRaw(diminui_ar, 59, 38);
  665. acao = 0;
  666. }
  667. // Fita Led
  668.  
  669. if (acao ==56){ // liga Fita Led
  670.  
  671. irsend.sendNEC(0xFF02FD, 32);
  672. acao = 0;
  673. }
  674. if (acao ==57){ //aumentaFita Led
  675.  
  676. irsend.sendNEC(0xFF3AC5, 32);
  677. acao = 0;
  678. }
  679. if (acao ==58){ // diminii Fita Led
  680.  
  681. irsend.sendNEC(0xFFBA45, 32);
  682. acao = 0;
  683. }
  684. if (acao ==59){ // azul Fita Led
  685.  
  686. irsend.sendNEC(0xFF1AE5, 32);
  687. acao = 0;
  688. }
  689. if (acao ==60){ // vermelho Fita Led
  690.  
  691. irsend.sendNEC(0xFF9A65, 32);
  692. acao = 0;
  693. }
  694. if (acao ==61){ // verde Fita Led
  695.  
  696. irsend.sendNEC(0xFFA25D, 32);
  697. acao = 0;
  698. }
  699. if (acao ==62){ // branco Fita Led
  700.  
  701. irsend.sendNEC(0xFF22DD, 32);
  702. acao = 0;
  703. }
  704. if (acao ==63){ // flash Fita Led
  705.  
  706. irsend.sendNEC(0xFFD02F, 32);
  707. acao = 0;
  708. }
  709. if (acao ==64){ // efeito 1 Fita Led
  710.  
  711. irsend.sendNEC(0xFF20DF, 32);
  712. acao = 0;
  713. }
  714. if (acao ==65){ // efeito 2 Fita Led
  715.  
  716. irsend.sendNEC(0xFFA05F, 32);
  717. acao = 0;
  718. }
  719. if (acao ==66){ // efeito 3 Fita Led
  720.  
  721. irsend.sendNEC(0xFF609F, 32);
  722. acao = 0;
  723. }
  724. if (acao ==67){ // efeito 4 Fita Led
  725.  
  726. irsend.sendNEC(0xFFE01F, 32);
  727. acao = 0;
  728. }
  729. if (acao ==68){ // Slow Fita Led
  730.  
  731. irsend.sendNEC(0xFFC837, 32);
  732. acao = 0;
  733. }
  734. if (acao ==69){ // Quick Fita Led
  735.  
  736. irsend.sendNEC(0xFFE817, 32);
  737. acao = 0;
  738. }
  739. ///////// // //// luz no controle ////////////////
  740. if (irrecv.decode(&results))
  741. {
  742. Serial.println(results.value, HEX);
  743. if (results.value == 0xFF946B) // LIGA QUARTO//
  744. {
  745. digitalWrite(pino_rele4, HIGH);
  746. }
  747. if (results.value == 0xFF0CF3) // DESLIGA QUARTO
  748. {
  749. digitalWrite(pino_rele4, LOW);
  750. }
  751.  
  752. if (results.value == 0xFF8C73) // LIGA BANHEIRO//
  753. {
  754. digitalWrite(pino_rele5, HIGH);
  755. }
  756. if (results.value == 0xFF4CB3) // DESLIGA BANHEIRO //
  757. {
  758. digitalWrite(pino_rele5, LOW);
  759. }
  760.  
  761.  
  762. irrecv.resume();
  763. }
  764. ///////
  765. } //Final do if
  766.  
  767. delay(1);
  768. irrecv.enableIRIn();
  769. client.stop();
  770. } //Final do if client
  771.  
  772. }//LOOP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement