//
___SETA43 _____ // 13/04/2021 _____ //Mando Infrarojo LG #include <IRremote.h> #define PinIR 4 #define OUT1 2 #define OUT2 3 IRrecv irrecv(PinIR); decode_results results; int codeType = -1; void setup() { Serial.begin(9600); pinMode(13, OUTPUT); pinMode(OUT1, OUTPUT);pinMode(OUT2, OUTPUT); Serial.println("HABILITAR IR-TREN"); irrecv.enableIRIn(); // Start the receiver } void loop() { if (irrecv.decode(&results)) { digitalWrite(13, HIGH); codeType = results.decode_type; switch (codeType) { case RC5: Serial.print("Received RC5: "); Serial.println(results.value & 255); break; case NEC: Serial.print("Received NEC: "); Serial.println(results.value & 255); Serial.println("-----------"); switch (results.value & 255) { case 253: digitalWrite(OUT1, LOW); delay(100); digitalWrite(OUT2, HIGH); break; case 125: digitalWrite(OUT2, LOW); delay(100); digitalWrite(OUT1, HIGH); break; case 221: digitalWrite(OUT2, LOW); digitalWrite(OUT1, LOW); break; } break; default: Serial.print("Unexpected codeType "); Serial.print(codeType, DEC); Serial.println("---"); break; } irrecv.resume(); // Receive the next value digitalWrite(13, LOW); } delay(20); } |