Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //char leitura;
- String leitura = " ";
- //1° bloco rele = lampadas
- #define ivan1 2 //A escritorio
- #define ivan2 3 //B quarto do igor
- #define ivan3 4 //C meu quarto
- #define ivan4 5 //D banheiro
- #define ivan5 6 //E copa
- #define ivan6 7 //F sala
- #define ivan7 8 //G area frente
- //2° bloco de rele = som ambiente
- #define ivan8 9 //H area fundo
- #define ivan9 10 //I chuveiro
- #define ivan10 11 //J luz colorida
- #define ivan11 12 //K portão
- #define ivan12 13 //L Dosador de ração
- #define ivan13 14 //M desativado
- #define ivan14 15 //N desativado
- #define ivan15 16 //O desativado
- #define ivan16 17 //P desativado
- //3° bloco de rele = som ambiente
- #define ivan17 18 //Q som escritorio
- #define ivan18 19 //R som cozinha
- #define ivan19 20 //S som quarto casal
- #define ivan20 21 //T som copa
- #define ivan21 22 //U som banheiro
- #define ivan22 23 //V som quarto filho
- #define ivan23 24 //W ativa som pendrive
- #define ivan24 25 //X som area frente
- //4°bloco de rele
- #define ivan25 26 //S desativado
- #define ivan26 27 //T desativado
- #define ivan27 28 //U desativado
- #define ivan28 29 //V desativado
- #define ivan29 30 //W desativado
- #define ivan30 31 //X desativado
- #define ivan31 32 //S desativado
- #define ivan32 33 //T desativado
- //5°bloco de rele
- #define ivan33 34 //U desativado
- #define ivan34 35 //V desativado
- #define ivan35 36 //W desativado
- #define ivan36 37 //X desativado
- #define ivan37 38 //S desativado
- #define ivan38 39 //T desativado
- #define ivan39 40 //U desativado
- #define ivan40 41 //V desativado
- #include <IRremote.h>
- IRsend irsend;
- //----------------------------------------------------
- void setup()
- {
- Serial.begin(9600);
- pinMode(ivan1, OUTPUT); digitalWrite (ivan1, HIGH);
- pinMode(ivan2, OUTPUT); digitalWrite (ivan2, HIGH);
- pinMode(ivan3, OUTPUT); digitalWrite (ivan3, HIGH);
- pinMode(ivan4, OUTPUT); digitalWrite (ivan4, HIGH);
- pinMode(ivan5, OUTPUT); digitalWrite (ivan5, HIGH);
- pinMode(ivan6, OUTPUT); digitalWrite (ivan6, HIGH);
- pinMode(ivan7, OUTPUT); digitalWrite (ivan7, HIGH);
- pinMode(ivan8, OUTPUT); digitalWrite (ivan8, HIGH);
- pinMode(ivan9, OUTPUT); digitalWrite (ivan9, HIGH);
- pinMode(ivan10, OUTPUT); digitalWrite (ivan10, HIGH);
- pinMode(ivan11, OUTPUT); digitalWrite (ivan11, HIGH);
- pinMode(ivan12, OUTPUT); digitalWrite (ivan12, HIGH);
- pinMode(ivan13, OUTPUT); digitalWrite (ivan13, HIGH);
- pinMode(ivan14, OUTPUT); digitalWrite (ivan14, HIGH);
- pinMode(ivan15, OUTPUT); digitalWrite (ivan15, HIGH);
- pinMode(ivan16, OUTPUT); digitalWrite (ivan16, HIGH);
- pinMode(ivan17, OUTPUT); digitalWrite (ivan17, HIGH);
- pinMode(ivan18, OUTPUT); digitalWrite (ivan18, HIGH);
- pinMode(ivan19, OUTPUT); digitalWrite (ivan19, HIGH);
- pinMode(ivan20, OUTPUT); digitalWrite (ivan20, HIGH);
- pinMode(ivan21, OUTPUT); digitalWrite (ivan21, HIGH);
- pinMode(ivan22, OUTPUT); digitalWrite (ivan22, HIGH);
- pinMode(ivan23, OUTPUT); digitalWrite (ivan23, HIGH);
- pinMode(ivan24, OUTPUT); digitalWrite (ivan24, HIGH);
- pinMode(ivan25, OUTPUT); digitalWrite (ivan25, HIGH);
- pinMode(ivan26, OUTPUT); digitalWrite (ivan26, HIGH);
- pinMode(ivan27, OUTPUT); digitalWrite (ivan27, HIGH);
- pinMode(ivan28, OUTPUT); digitalWrite (ivan28, HIGH);
- pinMode(ivan29, OUTPUT); digitalWrite (ivan29, HIGH);
- pinMode(ivan30, OUTPUT); digitalWrite (ivan30, HIGH);
- pinMode(ivan31, OUTPUT); digitalWrite (ivan31, HIGH);
- pinMode(ivan32, OUTPUT); digitalWrite (ivan32, HIGH);
- pinMode(ivan33, OUTPUT); digitalWrite (ivan33, HIGH);
- pinMode(ivan34, OUTPUT); digitalWrite (ivan34, HIGH);
- pinMode(ivan35, OUTPUT); digitalWrite (ivan35, HIGH);
- pinMode(ivan36, OUTPUT); digitalWrite (ivan36, HIGH);
- pinMode(ivan37, OUTPUT); digitalWrite (ivan37, HIGH);
- pinMode(ivan38, OUTPUT); digitalWrite (ivan38, HIGH);
- pinMode(ivan39, OUTPUT); digitalWrite (ivan39, HIGH);
- pinMode(ivan40, OUTPUT); digitalWrite (ivan40, HIGH);
- }
- //----------------------------------------------------
- void loop()
- {
- if (Serial.available() > 0)
- {
- // while (Serial.available() > 0)
- // {
- leitura = Serial.readString();
- // {
- if (leitura == "a" || leitura == "A") {
- digitalWrite(ivan1, !digitalRead(ivan1));
- Serial.println("to aqui");
- }
- else if (leitura == "b" || leitura == "B") {
- digitalWrite(ivan2, !digitalRead(ivan2));
- }
- else if (leitura == "c" || leitura == "C") {
- digitalWrite(ivan3, !digitalRead(ivan3));
- }
- if (leitura == "d" || leitura == "D") {
- digitalWrite(ivan4, !digitalRead(ivan4));
- }
- else if (leitura == "e" || leitura == "E") {
- digitalWrite(ivan5, !digitalRead(ivan5));
- }
- else if (leitura == "f" || leitura == "F") {
- digitalWrite(ivan6, !digitalRead(ivan6));
- }
- if (leitura == "g" || leitura == "G") {
- digitalWrite(ivan7, !digitalRead(ivan7));
- }
- else if (leitura == "h" || leitura == "H") {
- digitalWrite(ivan8, !digitalRead(ivan8));
- }
- else if (leitura == "i" || leitura == "I") {
- digitalWrite(ivan9, !digitalRead(ivan9));
- }
- if (leitura == "j" || leitura == "J") {
- digitalWrite(ivan10 , !digitalRead(ivan10));
- }
- //else if (leitura == "k" || leitura =="K"){
- //digitalWrite(ivan11,!digitalRead(ivan11));
- //}
- //else if (leitura == "l" || leitura =="L"){
- //digitalWrite(ivan12,!digitalRead(ivan12));
- //}
- if (leitura == "m" || leitura == "M") {
- digitalWrite(ivan13, !digitalRead(ivan13));
- }
- else if (leitura == "n" || leitura == "N") {
- digitalWrite(ivan14, !digitalRead(ivan14));
- }
- else if (leitura == "o" || leitura == "O") {
- digitalWrite(ivan15, !digitalRead(ivan15));
- }
- else if (leitura == "p" || leitura == "P") {
- digitalWrite(ivan16, !digitalRead(ivan16));
- }
- else if (leitura == "q" || leitura == "Q") {
- digitalWrite(ivan17, !digitalRead(ivan17));
- }
- if (leitura == "r" || leitura == "R") {
- digitalWrite(ivan18 , !digitalRead(ivan18));
- }
- else if (leitura == "s" || leitura == "S") {
- digitalWrite(ivan19, !digitalRead(ivan19));
- }
- else if (leitura == "t" || leitura == "T") {
- digitalWrite(ivan20, !digitalRead(ivan20));
- }
- if (leitura == "u" || leitura == "U") {
- digitalWrite(ivan21, !digitalRead(ivan21));
- }
- else if (leitura == "v" || leitura == "V") {
- digitalWrite(ivan22, !digitalRead(ivan22));
- }
- else if (leitura == "w" || leitura == "W") {
- digitalWrite(ivan23, !digitalRead(ivan23));
- }
- else if (leitura == "x" || leitura == "X") {
- digitalWrite(ivan24, !digitalRead(ivan24));
- }
- else if (leitura == "y" || leitura == "Y") {
- digitalWrite(ivan25, !digitalRead(ivan25));
- }
- else if (leitura == "z" || leitura == "Z") {
- digitalWrite(ivan26, !digitalRead(ivan26));
- }
- if (leitura == "L")
- {
- digitalWrite(13, LOW);
- Serial.print("Dosador de ração Ligado");
- delay(5000);
- digitalWrite(13, HIGH);
- Serial.print("Dosador de ração Desligado");
- }
- if (leitura == "K")
- {
- digitalWrite(12, LOW);
- Serial.print("Portão aberto");
- delay(1000);
- digitalWrite(12, HIGH);
- Serial.print("Portão fechado");
- }
- if (leitura == "1") //LIGAR AS LAMPADAS
- {
- digitalWrite (ivan1, LOW);
- digitalWrite (ivan2, LOW);
- digitalWrite (ivan3, LOW);
- digitalWrite (ivan4, LOW);
- digitalWrite (ivan5, LOW);
- digitalWrite (ivan6, LOW);
- digitalWrite (ivan7, LOW);
- digitalWrite (ivan8, LOW);
- //digitalWrite (ivan9,LOW); //chuveiro
- digitalWrite (ivan10, LOW);
- //digitalWrite (ivan11,LOW); //portao
- //digitalWrite (ivan12,LOW); //dosador de ração
- digitalWrite (ivan13, LOW);
- digitalWrite (ivan14, LOW);
- digitalWrite (ivan15, LOW);
- digitalWrite (ivan16, LOW);
- Serial.println(leitura);
- }
- if (leitura == "2") //LIGAR TODOS OS SOM
- {
- digitalWrite (ivan17, LOW);
- digitalWrite (ivan18, LOW);
- digitalWrite (ivan19, LOW);
- digitalWrite (ivan20, LOW);
- digitalWrite (ivan21, LOW);
- digitalWrite (ivan22, LOW);
- digitalWrite (ivan23, LOW);
- digitalWrite (ivan24, LOW);
- Serial.println(leitura);
- }
- if (leitura == "3") //DESLIGAR TODAS AS LAMPADAS
- {
- digitalWrite (ivan1, HIGH);
- digitalWrite (ivan2, HIGH);
- digitalWrite (ivan3, HIGH);
- digitalWrite (ivan4, HIGH);
- digitalWrite (ivan5, HIGH);
- digitalWrite (ivan6, HIGH);
- digitalWrite (ivan7, HIGH);
- digitalWrite (ivan8, HIGH);
- digitalWrite (ivan9, HIGH);
- digitalWrite (ivan10, HIGH);
- digitalWrite (ivan11, HIGH);
- digitalWrite (ivan12, HIGH);
- digitalWrite (ivan13, HIGH);
- digitalWrite (ivan14, HIGH);
- digitalWrite (ivan15, HIGH);
- digitalWrite (ivan16, HIGH);
- Serial.println(leitura);
- }
- if (leitura == "4") //DESLIGAR TODOS OS SOM
- {
- digitalWrite (ivan17, HIGH);
- digitalWrite (ivan18, HIGH);
- digitalWrite (ivan19, HIGH);
- digitalWrite (ivan20, HIGH);
- digitalWrite (ivan21, HIGH);
- digitalWrite (ivan22, HIGH);
- digitalWrite (ivan23, HIGH);
- digitalWrite (ivan24, HIGH);
- Serial.println(leitura);
- }
- if (leitura == "5") //DESLIGAR TUDO
- {
- digitalWrite (ivan1, HIGH);
- digitalWrite (ivan2, HIGH);
- digitalWrite (ivan3, HIGH);
- digitalWrite (ivan4, HIGH);
- digitalWrite (ivan5, HIGH);
- digitalWrite (ivan6, HIGH);
- digitalWrite (ivan7, HIGH);
- digitalWrite (ivan8, HIGH);
- digitalWrite (ivan9, HIGH);
- digitalWrite (ivan10, HIGH);
- digitalWrite (ivan11, HIGH);
- digitalWrite (ivan12, HIGH);
- digitalWrite (ivan13, HIGH);
- digitalWrite (ivan14, HIGH);
- digitalWrite (ivan15, HIGH);
- digitalWrite (ivan16, HIGH);
- digitalWrite (ivan17, HIGH);
- digitalWrite (ivan18, HIGH);
- digitalWrite (ivan19, HIGH);
- digitalWrite (ivan20, HIGH);
- digitalWrite (ivan21, HIGH);
- digitalWrite (ivan22, HIGH);
- digitalWrite (ivan23, HIGH);
- digitalWrite (ivan24, HIGH);
- digitalWrite (ivan25, HIGH);
- digitalWrite (ivan26, HIGH);
- digitalWrite (ivan27, HIGH);
- digitalWrite (ivan28, HIGH);
- digitalWrite (ivan29, HIGH);
- digitalWrite (ivan30, HIGH);
- digitalWrite (ivan31, HIGH);
- digitalWrite (ivan32, HIGH);
- digitalWrite (ivan33, HIGH);
- digitalWrite (ivan34, HIGH);
- digitalWrite (ivan35, HIGH);
- digitalWrite (ivan36, HIGH);
- digitalWrite (ivan37, HIGH);
- digitalWrite (ivan38, HIGH);
- digitalWrite (ivan39, HIGH);
- digitalWrite (ivan40, HIGH);
- }
- delay(1000);
- Serial.println(leitura);
- // }
- // }
- infraRed();
- }
- }
- //-------------------------------------------------------------
- void infraRed()
- {
- // switch (leitura)
- // {
- if (leitura == "aa")
- {
- irsend.sendNEC(0xFF609F, 32); //controle remoto lampada colorida
- Serial.println("Desligar lampada musical");
- }
- if (leitura == "ba")
- {
- irsend.sendNEC(0xFFE01F, 32); //controle remoto lampada colorida
- Serial.println("Ligar lampada musical");
- }
- if (leitura == "ca")
- {
- irsend.sendNEC(0xFFF00F, 32); //controle remoto lampada colorida
- Serial.println("Flash colorido lampada musical");
- }
- if (leitura == "da")
- {
- irsend.sendNEC(0xFFE817, 32); //controle remoto lampada colorida
- Serial.println("Strobo colorido lampada musical");
- }
- if (leitura == "ea")
- {
- irsend.sendNEC(0xFFD827, 32); //controle remoto lampada colorida
- Serial.println("Fade colorido lampada musical");
- delay(100);
- }
- if (leitura == "fa")
- {
- irsend.sendNEC(0xFFC837, 32); //controle remoto lampada colorida
- Serial.println("Smooth colorido lampada musical");
- }
- if (leitura == "ga")
- {
- irsend.sendNEC(0xFF8877, 32); //controle remoto lampada colorida
- Serial.println("Voltar musica lampada musical");
- }
- if (leitura == "ha")
- {
- irsend.sendNEC(0xFF08F7, 32); //controle remoto lampada colorida
- Serial.println("Play musical lampada musical");
- }
- if (leitura == "ia")
- {
- irsend.sendNEC(0xFF48B7, 32); //controle remoto lampada colorida
- Serial.println("Avançar musica lampada musical");
- }
- if (leitura == "ja")
- {
- irsend.sendNEC(0x40BFB847, 32);
- Serial.println("liga desliga projetor");
- }
- if (leitura == "ka")
- {
- irsend.sendNEC(0x40BF7887, 32); //Projetor de imagem
- Serial.println("Menu projetor");
- delay(100);
- }
- if (leitura == "la")
- {
- irsend.sendNEC(0x40BFF807, 32);//Projetor de imagem
- Serial.println("Entradas do projetor");
- delay(100);
- }
- if (leitura == "ma")
- {
- irsend.sendNEC(0x40BF38C7, 32);//Projetor de imagem
- Serial.println("Play/Pause do projetor");
- delay(100);
- }
- if (leitura == "na")
- {
- irsend.sendNEC(0x40BF906F, 32);//Projetor de imagem
- Serial.println("seta para cima do proetor");
- delay(100);
- }
- if (leitura == "oa")
- {
- irsend.sendNEC(0x40BF807F, 32);//Projetor de imagem
- Serial.println("seta para baixo do projetor");
- delay(100);
- }
- if (leitura == "pa")
- {
- irsend.sendNEC(0x40BFB04F, 32);//Projetor de imagem
- Serial.println("volume mais do projetor");
- delay(100);
- }
- if (leitura == "qa")
- {
- irsend.sendNEC(0x40BF8877, 32);//Projetor de imagem
- Serial.println("volume menos do projetor");
- delay(100);
- }
- if (leitura == "ra")
- {
- irsend.sendNEC(0x807F02FD, 32);//Midia center
- Serial.println("liga/desliga midia center");
- delay(100);
- }
- if (leitura == "sa")
- {
- irsend.sendNEC(0x807F08F7, 32);//Midia center
- Serial.println("volume menos do midia center");
- delay(100);
- }
- if (leitura == "ta")
- {
- irsend.sendNEC(0x807F18E7, 32);//Midia center
- Serial.println("volume mais do midia center");
- delay(100);
- }
- if (leitura == "ua")
- {
- irsend.sendNEC(0x807F8877, 32);//Midia center
- Serial.println("inicio de tela midia center");
- delay(100);
- }
- if (leitura == "va")
- {
- irsend.sendNEC(0x807F9867, 32);//Midia center
- Serial.println("voltar no midia center");
- delay(100);
- }
- if (leitura == "wa")
- {
- irsend.sendNEC(0x807F6897, 32);//Midia center
- Serial.println("seta para cima do midia center");
- delay(100);
- }
- if (leitura == "xa")
- {
- irsend.sendNEC(0x807F58A7, 32);//Midia center
- Serial.println("seta para baixo do midia center");
- delay(100);
- }
- if (leitura == "ya")
- {
- irsend.sendNEC(0x807F8A75, 32);//Midia center
- Serial.println("seta para esquerda do midia center");
- delay(100);
- }
- if (leitura == "za")
- {
- irsend.sendNEC(0x807F0AF5, 32);//Midia center
- Serial.println("seta para direita do midia center");
- delay(100);
- }
- if (leitura == "Aa")
- {
- irsend.sendNEC(0x807F32CD, 32);//Midia center
- Serial.println("menu do midia center");
- delay(100);
- }
- if (leitura == "Ba")
- {
- irsend.sendNEC(0x807FC837, 32);//Midia center
- Serial.println("okay do midia center");
- delay(100);
- }
- if (leitura == "Ca")
- {
- irsend.sendNEC(0x404050AF, 32);//Midia center
- Serial.println("ligar/desligar azamerica");
- delay(100);
- }
- if (leitura == "Da")
- {
- irsend.sendNEC(0x4040B04F, 32);//Midia center
- Serial.println("ok e lista azamerica");
- delay(100);
- }
- if (leitura == "Ea")
- {
- irsend.sendNEC(0x40BF50AF, 32);//Midia center
- Serial.println("seta para a esquerda projetor");
- delay(100);
- }
- if (leitura == "Fa")
- {
- irsend.sendNEC(0x40BF10EF, 32);//Midia center
- Serial.println("seta para a direita projetor");
- delay(100);
- }
- {
- if (leitura == "Ga")
- irsend.sendNEC(0x4040D02F, 32);//Midia center
- Serial.println("seta para cima azamerica");
- delay(100);
- }
- if (leitura == "Ha")
- {
- irsend.sendNEC(0x4040708F, 32);//Midia center
- Serial.println("seta para baixo azamedica");
- delay(100);
- }
- if (leitura == "Ia")
- {
- irsend.sendNEC(0x40408877, 32);//Midia center
- Serial.println("seta para a esquerda azamerica");
- delay(100);
- }
- if (leitura == "Ja")
- {
- irsend.sendNEC(0x404008F7, 32);//Midia center
- Serial.println("seta para a direita azamerica");
- delay(100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement