-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_ir.ino
42 lines (32 loc) · 918 Bytes
/
read_ir.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
#include <IRrecv.h>
#include "debug.h"
#define DEBUG 1
IRrecv* irRecv; // infrared sender
decode_results results;
//SET TO MATCH YOUR HARDWARE
#define SERIAL_BAUD_RATE 9600
#define RESET_PIN 0
#define IR_PIN 14
/*---------------------------------------*/
//Runs once, when device is powered on or code has just been flashed
void setup()
{
//if set wrong, your serial debugger will not be readable
Serial.begin(SERIAL_BAUD_RATE);
digitalWrite(RESET_PIN, LOW);
//initialize the IR
irRecv = new IRrecv(IR_PIN);
irRecv->enableIRIn(); // Start the receiver
digitalWrite(IR_PIN, HIGH);
debugPrint("Test");
}
/*---------------------------------------*/
//Runs constantly
void loop()
{
if (irRecv->decode(&results)) {
debugPrintlnHex(results.value);
delay(300);
irRecv->resume(); // Continue receiving
}
}