-
Notifications
You must be signed in to change notification settings - Fork 0
/
ir2rs232.ino
58 lines (46 loc) · 1.44 KB
/
ir2rs232.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
#include <IRremote.h>
#include <IRremoteInt.h>
#include <SoftwareSerial.h>
//------------------------------------------------------------------------------
// Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
//
int recvPin = 6;
IRrecv irrecv(recvPin);
/*
/ int blinkPin = 4;
/ IRrecv irrecv(recvPin, blinkPin); */
SoftwareSerial mySerial(10, 11); // RX, TX
//------------------------------------------------------------------------------
// We use this string for repeat commands
String lastCommand = String("");
//+=============================================================================
// Configure the Arduino
//
void setup ( )
{
mySerial.begin(9600); // RS232 output
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true);
}
//+=============================================================================
// Translate to RS232
//
void translate (decode_results *results)
{
switch ((results->value)) {
// INSERT YOUR DATA.TXT FROM HERE
// TO HERE
case 0xFFFFFFFF: mySerial.println(lastCommand); delay(45); break;
}
}
//+=============================================================================
// The repeating section of the code
//
void loop ( )
{
decode_results results; // Somewhere to store the results
if (irrecv.decode(&results)) { // Grab an IR code
translate(&results);
irrecv.resume(); // Prepare for the next value
}
}