Browse Source

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

phel 1 year 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 @@
1
+/*
2
+
3
+  IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
4
+
5
+  An IR detector/demodulator must be connected to the input RECV_PIN.
6
+
7
+  Version 0.1 July, 2009
8
+
9
+  Copyright 2009 Ken Shirriff
10
+
11
+  http://arcfn.com
12
+
13
+*/
14
+
15
+#include <IRremote.h> // Einbinden der Bibliothek
16
+
17
+int RECV_PIN = 2;  // Digitales Signal von Pin 11 abgreifen
18
+
19
+IRrecv irrecv(RECV_PIN);  // Bibliothek den Eingangs Pin mitteilen
20
+
21
+decode_results results; // Die Ergebnisse decodieren
22
+
23
+void setup()
24
+{
25
+  Serial.begin(9600); // Serielle Verbindung aktivieren
26
+  pinMode (13, OUTPUT);  // Pin 13 (LED) als Ausgang festlegen
27
+  irrecv.enableIRIn(); // Eingang auf Pin 11 aktivieren
28
+  // pinMode(2, INPUT_PULLUP);
29
+}
30
+
31
+void loop() {
32
+
33
+  if (irrecv.decode(&results))
34
+  {
35
+    irrecv.resume(); // Das Signal empfangen
36
+
37
+
38
+    switch (results.value) // Abhaengig vom Signal in den richtigen Modus springen
39
+    {
40
+
41
+      case 3838404932:
42
+        printIR(F("Swing Off, 20°C Cooling"), results);
43
+        break;
44
+
45
+      case 3690363426:
46
+        printIR(F("Swing Off, 21°C Cooling"), results);
47
+        break;
48
+
49
+      case 882009292:
50
+        printIR(F("Swing Off, 22°C Cooling"), results);
51
+        break;
52
+
53
+      case 3556311322:
54
+        printIR(F("Swing Off, 23°C Cooling"), results);
55
+        break;
56
+
57
+      case 3026199020:
58
+        printIR(F("Swing Off, 24°C Cooling, 1"), results);
59
+        break;
60
+
61
+case 2143461149:
62
+        printIR(F("Swing Off, 24°C Cooling, 2"), results);
63
+        break;
64
+        
65
+      case 4100230080:
66
+        printIR(F("Swing Off, 25°C Cooling"), results);
67
+        break;
68
+
69
+      case 1452498520:
70
+        printIR(F("Swing Off, 26°C Cooling, 1"), results);
71
+        break;
72
+
73
+        case 425423268:
74
+        printIR(F("Swing Off, 26°C Cooling, 2"), results);
75
+        break;
76
+
77
+          case 2246699793:
78
+        printIR(F("Swing Off, 26°C Cooling, 3"), results);
79
+        break;
80
+
81
+      case 790084768:
82
+        printIR(F("Swing Off, 27°C Cooling, 1"), results);
83
+        break;
84
+
85
+        case 773307150:
86
+        printIR(F("Swing Off, 27°C Cooling, 2"), results);
87
+        break;
88
+
89
+      case 2659219414:
90
+        printIR(F("Swing Off, 28°C Cooling, 1"), results);
91
+        break;
92
+
93
+      case 921814487:
94
+        printIR(F("Swing Off, 28°C Cooling, 2"), results);
95
+        break;
96
+
97
+      case 2359257124:
98
+        printIR(F("Swing Off, 29°C Cooling, 1"), results);
99
+        break;
100
+
101
+      case 891459092:
102
+        printIR(F("Swing Off, 29°C Cooling, 2"), results);
103
+        break;
104
+
105
+      case 2900425451:
106
+        printIR(F("Swing Off, 29°C Cooling, 3"), results);
107
+        break;
108
+
109
+      case 1053999984:
110
+        printIR(F("Swing Off, 29°C Cooling, 4"), results);
111
+        break;
112
+
113
+              case 2537206068:
114
+        printIR(F("Swing Off, 29°C Cooling, 5"), results);
115
+        break;
116
+
117
+      case 1620861574:
118
+        printIR(F("Swing Off, 30°C Cooling, 1"), results);
119
+        break;
120
+
121
+      case 3546591281:
122
+        printIR(F("Swing Off, 30°C Cooling, 2"), results);
123
+        break;
124
+
125
+      case 3703255839:
126
+        printIR(F("Swing Off, 30°C Cooling, 3 Fan 7"), results);
127
+        break;
128
+
129
+         case 3802299781:
130
+        printIR(F("Swing Off, 30°C Cooling, 4 Fan 7"), results);
131
+        break;
132
+
133
+
134
+      case 4294967295:
135
+        printIR(F("Failure"), results);
136
+        break;
137
+
138
+        
139
+      case 1298439238:
140
+        printIR(F("Swing Off, 19°C Cooling"), results);
141
+        break;
142
+
143
+      default:
144
+        printIR(F("Unknown"), results);
145
+    }
146
+  }
147
+}
148
+
149
+void printIR(String text, decode_results results)
150
+{
151
+  Serial.print(F("0b"));
152
+  Serial.print(results.value, BIN);
153
+  Serial.print(F(" 0x"));
154
+  Serial.print(results.value, HEX);
155
+  Serial.print(F(" "));
156
+  Serial.print(results.value, DEC);
157
+  Serial.print(F(" "));
158
+  Serial.print(text);
159
+  Serial.println(F(""));
160
+
161
+}
162
+

Loading…
Cancel
Save