-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Receive.ino
84 lines (67 loc) · 2.48 KB
/
Receive.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
Copyright (c) 2014-2015 NicoHood
See the readme for credit to other people.
IRL Receive
Receives IR signals from different protocols and prints them to the Serial monitor.
Choose your protocols that should be decoded. Remove the not used ones to save flash/ram/speed.
You can choose a custom debounce time to not trigger a button two times in a row too fast.
The following pins are usable for PinInterrupt or PinChangeInterrupt*:
Arduino Uno/Nano/Mini: All pins are usable
Arduino Mega: 10, 11, 12, 13, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64),
A11 (65), A12 (66), A13 (67), A14 (68), A15 (69)
Arduino Leonardo/Micro: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI)
HoodLoader2: All (broken out 1-7) pins are usable
Attiny 24/44/84: All pins are usable
Attiny 25/45/85: All pins are usable
Attiny 13: All pins are usable
Attiny 441/841: All pins are usable
ATmega644P/ATmega1284P: All pins are usable
PinChangeInterrupts* requires a special library which can be downloaded here:
https://github.com/NicoHood/PinChangeInterrupt
*/
// include PinChangeInterrupt library* BEFORE IRLremote to acces more pins if needed
//#include "PinChangeInterrupt.h"
#include "IRLremote.h"
// Choose a valid PinInterrupt or PinChangeInterrupt* pin of your Arduino board
#define pinIR 2
// Choose the IR protocol of your remote. See the other example for this.
CNec IRLremote;
//CPanasonic IRLremote;
//CHashIR IRLremote;
//#define IRLremote Sony12
#define pinLed LED_BUILTIN
void setup()
{
// Start serial debug output
while (!Serial);
Serial.begin(115200);
Serial.println(F("Startup"));
// Set LED to output
pinMode(pinLed, OUTPUT);
// Start reading the remote. PinInterrupt or PinChangeInterrupt* will automatically be selected
if (!IRLremote.begin(pinIR))
Serial.println(F("You did not choose a valid pin."));
}
void loop()
{
// Check if we are currently receiving data
//if (!IRLremote.receiving()) {
// Run code that disables interrupts, such as some led strips
//}
// Check if new IR protocol data is available
if (IRLremote.available())
{
// Light Led
digitalWrite(pinLed, HIGH);
// Get the new data from the remote
auto data = IRLremote.read();
// Print the protocol data
Serial.print(F("Address: 0x"));
Serial.println(data.address, HEX);
Serial.print(F("Command: 0x"));
Serial.println(data.command, HEX);
Serial.println();
// Turn Led off after printing the data
digitalWrite(pinLed, LOW);
}
}