0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

git push してくれるEMOボタン型のBLEキーボードをESP32で作ってみた

Last updated at Posted at 2022-10-22

目的

便利な左手用デバイスを作ってみようと思い、まずは一発ギャグでEMOボタン型のキーボード作ってみました。Bluetoothで接続されます。

ハードウェア

以下、Amazonで購入
EMOボタン
ESP32ボード

ESP32はなんでもいいんじゃないかと思います。Arduinoでも大丈夫です。PIN19を使ってます。

リポジトリ

https://github.com/takurot/EmoKeyboard

ライブラリ

https://github.com/T-vK/ESP32-BLE-Keyboard

コード

ほぼライブラリのサンプルコードのままですが、HIGH->LOWのエッジ検出だけいれてます。ボタンを押すとLOWでリリースされるとHIGHです。

#include <BleKeyboard.h>

BleKeyboard bleKeyboard("EMO Keyboard");
int curSwitchState = HIGH;
int prevSwitchState = HIGH;

void setup() {
  Serial.begin(115200);
  Serial.println("Starting BLE work!");
  bleKeyboard.begin();
  pinMode(19, INPUT_PULLUP);
  curSwitchState = digitalRead(19);
  prevSwitchState = curSwitchState;
}

void loop() {
  if(bleKeyboard.isConnected()) {
    curSwitchState = digitalRead(19);
    if(prevSwitchState == HIGH && curSwitchState == LOW){
      // git push
      bleKeyboard.print("git push");
      delay(100);
      bleKeyboard.write(KEY_RETURN);
    }
    prevSwitchState = curSwitchState;
  }

  delay(300);
}

使い方

PCでBluetoothで「EMO Keyboard」を探してペアリングしてください。Macだとキーボード認識のフローに入りますが、EMOボタンを一回押すと次に進み、標準101キーボードとかを選べば認識されます。EMOボタンはボタン上の矢印の方向に回すとボタンがリリースされて、押し込むと保持されます。

最後に

思いの外簡単にカスタムキーボードが作れることがわかりました。ESP32はなんでもできますね。もっといろんなものをカスタムキーボード化してみようと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?