-
Notifications
You must be signed in to change notification settings - Fork 42
/
9.2.4-PPT.ino
56 lines (51 loc) · 1.07 KB
/
9.2.4-PPT.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
/*
按键对应关系:
ON> FFA25D
OFF>FFE21D
UP> FF9867
DOWN> FFB04F
*/
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup(){
Serial.begin(9600);
// 开始接收红外信号
irrecv.enableIRIn();
}
void loop()
{
// 接收红外编码
if (irrecv.decode(&results))
{
Serial.println(results.value, HEX);
// 准备接收下一次编码
irrecv.resume();
}
switch (results.value)
{
// 遥控器ON键>键盘F5键>开始播放
case 0xFFA25D:
Keyboard.press(KEY_F5);
Keyboard.releaseAll();
break;
// 遥控器OFF键>键盘Esc键>退出播放
case 0xFFE21D:
Keyboard.press(KEY_ESC);
Keyboard.releaseAll();
break;
// 遥控器向上键>键盘Esc键>退出播放
case 0xFF9867:
Keyboard.press(KEY_LEFT_ARROW);
Keyboard.releaseAll();
break;
// 遥控器向下键>键盘Esc键>退出播放
case 0xFFB04F:
Keyboard.press(KEY_RIGHT_ARROW);
Keyboard.releaseAll();
break;
}
// 清空编码数据,开始下一次接收
results.value = 0;
}