Browse Source

Initial code, working with arduino pro mini. Output of IR to serial console

master
phel 2 years ago
commit
de57c0b0a4
1 changed files with 162 additions and 0 deletions
  1. 162
    0
      esp32_ir.ino

+ 162
- 0
esp32_ir.ino View File

@@ -0,0 +1,162 @@
/*

IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv

An IR detector/demodulator must be connected to the input RECV_PIN.

Version 0.1 July, 2009

Copyright 2009 Ken Shirriff

http://arcfn.com

*/

#include <IRremote.h> // Einbinden der Bibliothek

int RECV_PIN = 2; // Digitales Signal von Pin 11 abgreifen

IRrecv irrecv(RECV_PIN); // Bibliothek den Eingangs Pin mitteilen

decode_results results; // Die Ergebnisse decodieren

void setup()
{
Serial.begin(9600); // Serielle Verbindung aktivieren
pinMode (13, OUTPUT); // Pin 13 (LED) als Ausgang festlegen
irrecv.enableIRIn(); // Eingang auf Pin 11 aktivieren
// pinMode(2, INPUT_PULLUP);
}

void loop() {

if (irrecv.decode(&results))
{
irrecv.resume(); // Das Signal empfangen


switch (results.value) // Abhaengig vom Signal in den richtigen Modus springen
{

case 3838404932:
printIR(F("Swing Off, 20°C Cooling"), results);
break;

case 3690363426:
printIR(F("Swing Off, 21°C Cooling"), results);
break;

case 882009292:
printIR(F("Swing Off, 22°C Cooling"), results);
break;

case 3556311322:
printIR(F("Swing Off, 23°C Cooling"), results);
break;

case 3026199020:
printIR(F("Swing Off, 24°C Cooling, 1"), results);
break;

case 2143461149:
printIR(F("Swing Off, 24°C Cooling, 2"), results);
break;
case 4100230080:
printIR(F("Swing Off, 25°C Cooling"), results);
break;

case 1452498520:
printIR(F("Swing Off, 26°C Cooling, 1"), results);
break;

case 425423268:
printIR(F("Swing Off, 26°C Cooling, 2"), results);
break;

case 2246699793:
printIR(F("Swing Off, 26°C Cooling, 3"), results);
break;

case 790084768:
printIR(F("Swing Off, 27°C Cooling, 1"), results);
break;

case 773307150:
printIR(F("Swing Off, 27°C Cooling, 2"), results);
break;

case 2659219414:
printIR(F("Swing Off, 28°C Cooling, 1"), results);
break;

case 921814487:
printIR(F("Swing Off, 28°C Cooling, 2"), results);
break;

case 2359257124:
printIR(F("Swing Off, 29°C Cooling, 1"), results);
break;

case 891459092:
printIR(F("Swing Off, 29°C Cooling, 2"), results);
break;

case 2900425451:
printIR(F("Swing Off, 29°C Cooling, 3"), results);
break;

case 1053999984:
printIR(F("Swing Off, 29°C Cooling, 4"), results);
break;

case 2537206068:
printIR(F("Swing Off, 29°C Cooling, 5"), results);
break;

case 1620861574:
printIR(F("Swing Off, 30°C Cooling, 1"), results);
break;

case 3546591281:
printIR(F("Swing Off, 30°C Cooling, 2"), results);
break;

case 3703255839:
printIR(F("Swing Off, 30°C Cooling, 3 Fan 7"), results);
break;

case 3802299781:
printIR(F("Swing Off, 30°C Cooling, 4 Fan 7"), results);
break;


case 4294967295:
printIR(F("Failure"), results);
break;

case 1298439238:
printIR(F("Swing Off, 19°C Cooling"), results);
break;

default:
printIR(F("Unknown"), results);
}
}
}

void printIR(String text, decode_results results)
{
Serial.print(F("0b"));
Serial.print(results.value, BIN);
Serial.print(F(" 0x"));
Serial.print(results.value, HEX);
Serial.print(F(" "));
Serial.print(results.value, DEC);
Serial.print(F(" "));
Serial.print(text);
Serial.println(F(""));

}


Loading…
Cancel
Save