Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Quarto automacao Lucas 2016//
- //versao 1.4//
- #include <IRremote.h>
- #include <IRremoteInt.h>
- IRsend irsend;
- const int RECV_PIN = 2;
- const int Rele = 8;
- IRrecv irrecv(RECV_PIN);
- decode_results results;
- int led = 9;
- int ch1 = 3;
- int ch2 = 5;
- int ch3 = 6;
- int ch4 = 4;
- /// Home Teather//
- 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,};
- 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,};
- 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,};
- 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,};
- 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,};
- 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,};
- 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,};
- 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,};
- 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,};
- /// ar condicionado
- 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,};
- 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,};
- 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,};
- 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,};
- 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,};
- 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,};
- //---------------------------------------------------------
- void setup()
- {
- Serial.begin(9600);
- Serial3.begin(9600);
- byte rx_byte = 0; // stores received byte
- pinMode(led,OUTPUT); //infravermelho;
- pinMode(ch1, OUTPUT);//Pino digital saÃda do Arduino(4-ch1);
- pinMode(ch2, OUTPUT);//Pino digital saÃda do Arduino(5-ch2);
- pinMode(ch3, OUTPUT);//Pino digital saÃda do Arduino(6-ch3);
- pinMode(ch4, OUTPUT);//Pino digital saÃda do Arduino(7-ch4);
- pinMode(Rele,OUTPUT);
- irrecv.enableIRIn();
- }
- //---------------------------------------------------------
- void loop() {
- Serial3.println("mensagem");
- if (irrecv.decode(&results))
- {
- Serial3.println(results.value, HEX);
- if(results.value == 0xFF946B) // LIGA QUARTO//
- {
- digitalWrite(ch1, HIGH);
- }
- if(results.value == 0xFF0CF3) // DESLIGA QUARTO
- {
- digitalWrite(ch1, LOW);
- }
- if(results.value == 0xFF8C73) // LIGA BANHEIRO//
- {
- digitalWrite(ch4, HIGH);
- }
- if(results.value == 0xFF4CB3) // DESLIGA BANHEIRO //
- {
- digitalWrite(ch4, LOW);
- }
- irrecv.resume();
- }
- if (Serial3.available() > 0)
- {
- char valorlido = Serial3.read();
- switch(valorlido)
- {
- // controle Receptor ///
- case 'E': irsend.sendNEC (0xFF50AF, 32);break; // Power break;
- case 'F': irsend.sendNEC (0xFFB04F, 32);break; // Botao OK ;
- case 'P': irsend.sendNEC (0xFF8877, 32);break; // SETA PRA DIREITA ;
- case 'Q': irsend.sendNEC (0xFF08F7, 32);break; // SETA PRA ESQUERDA ;
- case 'R': irsend.sendNEC (0xFFD02F, 32);break; // SETA PRA CIMA ;
- case 'S': irsend.sendNEC (0xFF708F, 32);break; // SETA PRA BAIXO ;
- case 'T': irsend.sendNEC (0xFF7887, 32);break; // EXIT ;
- case 'U': irsend.sendNEC (0xFF6C93, 32);break; // SLEEP ;
- case 'V': irsend.sendNEC (0xFF58A7, 32);break; // MENU ;
- case 'W': irsend.sendNEC (0xFFEA15, 32);break; // FAVORITO ;
- case 'B': irsend.sendNEC (0xFFCC33, 32);break; // MUDO ;
- case 'n': irsend.sendNEC (0xFF2CD3, 32);break; // tv radio ;
- case 'o': irsend.sendNEC (0xFF807F, 32);break; // 1 ;
- case 'p': irsend.sendNEC (0xFF40BF, 32);break; // 2 ;
- case 'q': irsend.sendNEC (0xFFC03F, 32);break; // 3 ;
- case 'r': irsend.sendNEC (0xFF20DF, 32);break; // 4 ;
- case 's': irsend.sendNEC (0xFFA05F, 32);break; // 5 ;
- case 't': irsend.sendNEC (0xFF609F, 32);break; // 6 ;
- case 'u': irsend.sendNEC (0xFFE01F, 32);break; // 7 ;
- case 'v': irsend.sendNEC (0xFF10EF, 32);break; // 8 ;
- case 'y': irsend.sendNEC (0xFF906F, 32);break; // 9 ;
- case 'C': irsend.sendNEC (0xFF00FF, 32);break; // 0 ;
- //Controle da tv //
- case 'a': irsend.sendNEC (0x2FD48B7, 32);break; // Power break;
- case 'b': irsend.sendNEC (0x2FDF00F, 32);break; // Input;
- case 'c': irsend.sendNEC (0x2FD01FE, 32);break; // Menu;
- case 'd': irsend.sendNEC (0x2FD41BE, 32);break; // Tecla Cima;
- case 'e': irsend.sendNEC (0x2FDC13E, 32);break; // Tecla Baixo;
- case 'f': irsend.sendNEC (0x2FDB847, 32);break; // Tecla Esquerda;
- case 'g': irsend.sendNEC (0x2FD9867, 32);break; // Tecla Direita;
- case 'h': irsend.sendNEC (0x2FD58A7, 32);break; // Volume +;
- case 'i': irsend.sendNEC (0x2FD7887, 32);break; // Volume -;
- case 'j': irsend.sendNEC (0x2FD1AE5, 32);break; // Exit;
- case 'k': irsend.sendNEC (0x2FD9B64, 32);break; // voltar;
- case 'l': irsend.sendNEC (0x2FD08F7, 32);break; // Mute;
- case 'z': irsend.sendNEC (0x2FD916E, 32);break; // Enter;
- case 'D': irsend.sendNEC (0x2FDA857, 32);break; // Sleep:
- case 'X': irsend.sendNEC (0x2FD54AB, 32);break; // Netflix:
- //case 'A': irsend.sendNEC (0x2FD20DF, 32);break; // Sbt:
- //case 'C': irsend.sendNEC (0x2FDE01F, 32);break; // Record:
- //Controle Home;
- case 'G': irsend.sendRaw (S_pwr,67, 38);break; // Power break;
- case 'H': irsend.sendRaw (S_fca,67, 38);break; // funcao;
- case 'I': irsend.sendRaw (S_vol,67, 38);break; // Volume - ;
- case 'J': irsend.sendRaw (S_volm,67, 38);break; // Volume +;
- case 'K': irsend.sendRaw (S_ant,67, 38);break; // anterior;
- case 'L': irsend.sendRaw (S_ava,67, 38);break; // avancar;
- case 'M': irsend.sendRaw (S_pla,67, 38);break; //play;
- case 'N': irsend.sendRaw (S_cim,67, 38);break; //cima;
- case 'O': irsend.sendRaw (S_bai,67, 38);break;//baixo;
- ///Ar condicionado
- case 'Y': irsend.sendRaw (des_ar,59, 38);break;//Desligar
- case 'A': irsend.sendRaw (modo_ar,59, 38);break;//modo ok
- case 'x': irsend.sendRaw (velocidade_ar,61, 38);break;//velocidade Ok
- case 'w': irsend.sendRaw (aumenta_ar,59, 38);break;//aumenta ok
- case 'Z': irsend.sendRaw (diminui_ar,59, 38);break;//diminui
- case 'm': irsend.sendRaw (lig_ar,59, 38);break;//Ligar
- //LAMPADAS:
- //CANAL 1//
- case '1':digitalWrite(ch1, !digitalRead(ch1));break;//Quarto;
- case '5':digitalWrite(ch2, !digitalRead(ch2));break;//NULO;
- case '3':digitalWrite(ch3, !digitalRead(ch3));break;//escada;
- case '4':digitalWrite(ch4, !digitalRead(ch4));break; // Banheiro
- }
- irrecv.enableIRIn();
- }
- delay(10);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement