1
12
13#include <irremote.h>
14int RECV_PIN = 11;
15int LED_PIN = 2;
16int commandExecuted = 0;
17
18
19
20const long play = 0x800F046E;
21const long volumeUp= 0x800F0410;
22const long volumeDown= 0x800F8411;
23const long forward= 0x800F8414;
24const long backward= 0x800F0415;
25const long mute= 0x800F040E;
26
27
28
29IRrecv irrecv(RECV_PIN);
30decode_results results;
31
32void setup()
33{
34 pinMode(LED_PIN,OUTPUT);
35 digitalWrite(LED_PIN,LOW);
36 irrecv.enableIRIn();
37 Keyboard.begin();
38}
39
40void loop() {
41 if (irrecv.decode(&results)) {
42 switch(results.value){
43 case play:
44 Keyboard.press(' ');
45 commandExecuted = 1;
46 break;
47 case volumeUp:
48 Keyboard.press(KEY_LEFT_CTRL);
49 Keyboard.press(KEY_UP_ARROW);
50 commandExecuted = 1;
51 break;
52 case volumeDown:
53 Keyboard.press(KEY_LEFT_CTRL);
54 Keyboard.press(KEY_DOWN_ARROW);
55 commandExecuted = 1;
56 break;
57 case forward:
58 Keyboard.press(KEY_LEFT_CTRL);
59 Keyboard.press(KEY_RIGHT_ARROW);
60 commandExecuted = 1;
61 break;
62 case backward:
63 Keyboard.press(KEY_LEFT_CTRL);
64 Keyboard.press(KEY_LEFT_ARROW);
65 commandExecuted = 1;
66 break;
67 case mute:
68 Keyboard.press('m');
69 commandExecuted = 1;
70 break;
71 }
72 if ( commandExecuted == 1) {
73 digitalWrite(LED_PIN,HIGH);
74 commandExecuted = 0;
75 }
76 delay(100);
77 digitalWrite(LED_PIN,LOW);
78 Keyboard.releaseAll();
79
80 irrecv.resume();
81 }
82}