1
10
11
12#include <IRremote.h>
13
14
15IRrecv irrecv(3);
16
17
18decode_results data;
19
20bool state1 = 0;
21bool state2 = 0;
22int led1 = 8;
23int led2 = 9;
24
25
26#define btn1 0x0
27#define btn2 0x0
28
29void setup() {
30
31
32 pinMode(led1, OUTPUT);
33 pinMode(led2, OUTPUT);
34
35
36 Serial.begin(9600);
37
38
39 irrecv.enableIRIn();
40}
41
42void loop() {
43
44 if (irrecv.decode(&data)) {
45
46
47 Serial.print("0x");
48 Serial.println(data.value, HEX);
49 delay(1000);
50 irrecv.resume();
51
52 if (data.value == btn1) {
53
54
55 state1 = !state1;
56 digitalWrite(led1, state1);
57
58
62 irrecv.disableIRIn();
63 delay(500);
64 irrecv.enableIRIn();
65
66 }
67
68 else if (data.value == btn2) {
69
70
71 state2 = !state2;
72 digitalWrite(led2, state2);
73
74
78 irrecv.disableIRIn();
79 delay(500);
80 irrecv.enableIRIn();
81
82 }
83 }
84}
85