108个传感器之-游戏手柄 adkeyboard(41)

108个传感器之-游戏手柄 adkeyboard(41)

介绍

游戏

代码示例

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
#include <Arduino.h>
#include <ezAnalogKeypad.h>

ezAnalogKeypad keypad(A2); // create ezAnalogKeypad object that attach to pin A0

void setup() {
Serial.begin(9600);

// MUST READ: You MUST run the calibration example, press key one-by-one to get the analog values
// The below values is just an example, your keypad's value may be different
keypad.setNoPressValue(0); // analog value when no key is pressed
keypad.registerKey('1', 100); // analog value when the key '1' is pressed
keypad.registerKey('2', 150); // analog value when the key '2' is pressed
keypad.registerKey('3', 200); // analog value when the key '3' is pressed
keypad.registerKey('4', 250); // analog value when the key '4' is pressed
keypad.registerKey('*', 450); // analog value when the key '*' is pressed
keypad.registerKey('0', 500); // analog value when the key '0' is pressed
keypad.registerKey('#', 550); // analog value when the key '#' is pressed
keypad.registerKey('d9', 4095); // analog value when the key '#' is pressed
}

void loop() {
unsigned char key = keypad.getKey();
if (key) {
Serial.println(key);
}
}

108个传感器之-游戏手柄 adkeyboard(41)

https://blog.jzxer.cn/20250113/20250113_ad_keyboard/

作者

dev

发布于

2025-01-13

更新于

2025-11-09

许可协议

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×