forked from fcwu/iremote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ir-tx.cpp
44 lines (40 loc) · 1.29 KB
/
ir-tx.cpp
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
#include <Arduino.h>
#include <HardwareSerial.h>
#include <IRremote.h>
const int buttonPin = 4;
int buttonState = 0;
IRsend irsend;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int d;
unsigned long code = 0;
if ((d = Serial.read()) != -1) {
switch (d) {
case '1': code = 0x1CE3807F; break;
case '2': code = 0x1CE340BF; break;
case '3': code = 0x1CE3C03F; break;
case '4': code = 0x1CE320DF; break;
case '5': code = 0x1CE3A05F; break;
case '6': code = 0x1CE3609F; break;
case '7': code = 0x1CE3E01F; break;
case '8': code = 0x1CE310EF; break;
case '9': code = 0x1CE3906F; break;
case '0': code = 0x1CE300FF; break;
case 'q': code = 0x1CE3708F; break; // volume up
case 'a': code = 0x1CE3F00F; break; // volume down
case 'w': code = 0x1CE350AF; break; // channel up
case 's': code = 0x1CE3D02F; break; // channel down
case 'e': code = 0x1CE3C837; break; // source
case 'd': code = 0x1CE3A25D; break; // enter
case 'p': code = 0x1CE348B7; break; // power
default: code = 0;
}
if (code != 0) {
irsend.sendNEC(code, 32);
}
}
}