-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathir_remote.ino
63 lines (61 loc) · 1.25 KB
/
ir_remote.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
int pin2 = 2, pin3 = 3, pin4 = 4, pin5 = 5;
int i = 0;
// Red Power Button fn
void onoff(int input){
Serial.println(input);
if((input==18615) && i==0){
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
i=1;
}
else if((input==18615) && i==1){
digitalWrite(pin2, LOW);
digitalWrite(pin3, LOW);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
i=0;
}
//btn 1
else if(input==20655){
digitalWrite(pin2, !digitalRead(pin2));
i=1;
}
//btn 2
else if(input==-10201){
digitalWrite(pin3, !digitalRead(pin3));
i=1;
}
// btn 3
else if(input==-2041){
digitalWrite(pin4, !digitalRead(pin4));
i=1;
}
// btn 4
else if(input==12495){
digitalWrite(pin5, !digitalRead(pin5));
i=1;
}
}
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
onoff(results.value);
irrecv.resume(); // Receive the next value
}
//delay(100);
}