-
Notifications
You must be signed in to change notification settings - Fork 11
/
RC5Decode.ino
executable file
·45 lines (41 loc) · 972 Bytes
/
RC5Decode.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
/*
* Wiring notes:
*
* Using IR sensor like this:
* http://www.adafruit.com/products/157
* wired as follows:
* pin1 - arduino pin 7
* pin2 - ground
* pin3 - 5V
*
* This code will display address, command and toggle for decoded sequences.
* Pressing the power button twice gives this result:
* a:0 c:12 t:0 <- first press, a:0 => TV1, c:12 => Standby command.
* a:0 c:12 t:0
* a:0 c:12 t:0
* a:0 c:12 t:1 <- second press, toggle changes
* a:0 c:12 t:1
*
*/
#include <RC5.h>
int IR_PIN = 7;
unsigned long t0;
RC5 rc5(IR_PIN);
void setup() {
Serial.begin(9600);
Serial.println("Starting");
}
void loop() {
unsigned char toggle;
unsigned char address;
unsigned char command;
if (rc5.read(&toggle, &address, &command))
{
Serial.print("a:");
Serial.print(address);
Serial.print(" c:");
Serial.print(command);
Serial.print(" t:");
Serial.println(toggle);
}
}