-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemote_LED.ino
More file actions
53 lines (42 loc) · 999 Bytes
/
Remote_LED.ino
File metadata and controls
53 lines (42 loc) · 999 Bytes
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
#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>
#define BUTTON_UP 0xFF18E7
#define BUTTON_DOWN 0xFF4AB5
int ledPin = 7;
int recvPin = 11;
IRrecv irrecv(recvPin);
decode_results results;
void setup(){
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
irrecv.enableIRIn();
}
//+=============================================================================
// Display IR code
//
void ircode (decode_results *results)
{
// Panasonic has an Address
if (results->decode_type == PANASONIC) {
Serial.print(results->address, HEX);
Serial.print(":");
}
// Print Code
Serial.print(results->value, HEX);
}
void loop() {
if(irrecv.decode(&results)) {
Serial.print("CODE: ");
ircode(&results);
Serial.println("");
if(results.value == BUTTON_UP) {
digitalWrite(ledPin, HIGH);
}
else if(results.value == BUTTON_DOWN) {
digitalWrite(ledPin, LOW);
}
irrecv.resume();
}
}