-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.ino
51 lines (42 loc) · 916 Bytes
/
sketch.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
#include <IRremote.h>
//use pin 9/10 to control up/down, change here
const int upPin = 9;
const int downPin = 10;
//IR receiver pin 11
const int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
//change the hex code here
unsigned long upButton = 0x123456;
unsigned long downButton = 0x654321;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(upPin, OUTPUT);
pinMode(downPin, OUTPUT);
}
void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, HEX);
if(results.value == upButton)
{
digitalWrite(upPin, HIGH);
Serial.println("Motor up");
}
else if(results.value == downButton)
{
digitalWrite(downPin, HIGH);
Serial.println("Motor down");
}
irrecv.resume();
}
else
{
digitalWrite(upPin, LOW);
digitalWrite(downPin, LOW);
}
delay(50);
}