核弹按钮
夏佳怡核弹按钮
前言
材料准备
- ESP32-WROOM-32(CH340 芯片)
- 急停开关
接线
将 D13 引脚和 GND 引脚接到开关两侧
将 D13 引脚和 GND 引脚连通时,也就是 D13 引脚接地,就会触发按键
烧录源码
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
| #include <BleKeyboard.h> #define run 13
BleKeyboard bleKeyboard("核弹按钮", "XiaJiayi", 100);
void setup() { void alt(void); Serial.begin(115200); Serial.println("Starting BLE work!"); bleKeyboard.begin(); pinMode(run, INPUT_PULLUP); }
void loop() { if (bleKeyboard.isConnected()) { if (digitalRead(run) == 0) { delay(20); bleKeyboard.press(KEY_LEFT_CTRL); bleKeyboard.press(KEY_LEFT_SHIFT); bleKeyboard.write(KEY_F10); delay(100); bleKeyboard.releaseAll(); while (digitalRead(run) == 0) ; delay(20); } } }
|