23 #include "IRreceiver.h"
24 #if defined(ARDUINO) && ARDUINO >= 100
161 void _IR_receive_interrupt(
void)
163 receiver->handleInterrupt();
187 switch (interruptNumber) {
188 case 0:
default: pin = 2;
break;
189 case 1: pin = 3;
break;
190 case 2: pin = 21;
break;
191 case 3: pin = 20;
break;
192 case 4: pin = 19;
break;
193 case 5: pin = 18;
break;
196 attachInterrupt(interruptNumber, _IR_receive_interrupt, CHANGE);
235 if (_systemFilter != -1) {
236 if (((buf >> 6) & 0x1F) != _systemFilter) {
243 int cmd = buf & 0x3F;
244 if ((buf & 0x1000) == 0)
249 if (lastBuffer == buf)
253 _system = (buf >> 6) & 0x1F;
307 #define IR_BIT_TIME 889
313 #define IR_LONG_BIT_TIME (889 * 6 / 4)
317 #define IR_MAX_TIME (IR_BIT_TIME * 4)
320 void IRreceiver::handleInterrupt()
322 bool value = digitalRead(pin);
323 unsigned long currentTime = micros();
326 if (started && (currentTime - lastChange) > IR_MAX_TIME) {
333 if ((currentTime - lastChange) > IR_LONG_BIT_TIME) {
338 halfChange = !halfChange;
340 lastChange = currentTime;
343 lastChange = currentTime;
349 }
else if (started) {
351 if ((currentTime - lastChange) > IR_LONG_BIT_TIME) {
353 bits = (bits << 2) | 0x02;
356 }
else if (halfChange) {
358 bits = (bits << 1) | 0x01;
365 lastChange = currentTime;
IRreceiver(int interruptNumber=0)
Constructs a new infrared remote control receiver that is attached to interruptNumber.
Manages the reception of RC-5 commands from an infrared remote control.
int command()
Returns the next command from the remote control.
static const int AUTO_REPEAT
Flag that is added to the output of command() when the command is an auto-repeated button press rathe...