iTranslated by AI
Building a Simple Presentation Remote with M5ATOM (ESP32)
I have created a "simple presentation remote" for advancing slides in PowerPoint or PDF presentations, using an ESP32 library that turns it into a BLE keyboard for the Arduino IDE environment.
What I Built
For this device, I used the M5ATOM Lite, which is a compact module from M5Stack.
The M5ATOM Lite packs an ESP32, a full-color LED, and a button into a compact 2.5x2.5cm case. It is highly recommended due to its excellent cost-performance, priced at $5.95 in the official store, or about 968 yen if purchased from Switch Science.
How to Build
Installing the ESP32 BLE Keyboard library
Since it is published by T-vk on GitHub, download it and extract it into the Library folder of your Arduino IDE.
ESP32 BLE Keyboard library
There is a sketch called SendKeyStrokes in the examples, which I used as a reference.
General Specifications
If you search for presentation remotes on Amazon, they typically cost around 2,500 yen. Since all I really needed was basic slide advancement, I focused this on page navigation for Windows PC presentations.
- Short-pressing the M5ATOM button advances to the next page (sends the Right Arrow key).
- Long-pressing the M5ATOM button returns to the previous page (sends the Left Arrow key).
- The long-press duration is stored as a variable (to make debugging easier).
- The PC connection status and button actions are indicated by changing the color of the LED on the M5ATOM Lite.
The Sketch
The code is very simple. I decided to use the M5.btn function for long-press detection.
Once the button ON state is detected, the program waits for a certain period before checking the button status again to determine the action.
The M5.Btn.wasPressed() function triggers only once when the key state changes from OFF to ON, so processing within this function prevents continuous operation while the button is held down.
#include "M5Atom.h"
#include <BleKeyboard.h> // https://github.com/T-vK/ESP32-BLE-Keyboard
BleKeyboard bleKeyboard("M5ATOM KB"); // Device name
const int longPress_ms = 300; // Long press detection duration (in msec)
void setup() {
// M5.begin(SerialEnable, I2CEnable, DisplayEnable);
M5.begin(true, false, true);
M5.dis.drawpix(0, 0x000000); // LED OFF
//Serial.begin(115200);
Serial.println("Starting BLE work!");
bleKeyboard.begin();
}
void loop() {
M5.update();
if(bleKeyboard.isConnected()){
if(M5.Btn.wasPressed()){
// Wait for a certain time once the M5ATOM button is pressed
delay(longPress_ms);
if(M5.Btn.read() == true){ // If the key is still pressed, detect as a long press
M5.dis.drawpix(0, 0x00f0f0); // LED MAGENTA
Serial.println("<-Page Back");
bleKeyboard.write(KEY_LEFT_ARROW);
delay(100);
}else{ // If the key is released, detect as a short press
M5.dis.drawpix(0, 0xf00000); // LED GREEN
Serial.println("Page Forward->");
bleKeyboard.write(KEY_RIGHT_ARROW);
delay(100);
}
}
M5.dis.drawpix(0, 0x0000f0); // LED BLUE
}else{
M5.dis.drawpix(0, 0x00f000); // LED RED
}
delay(10);
}
Summary
By changing the key codes sent, you can also use this for tasks like password entry or window operations.
Check the header file (BleKeyboard.h) of the ESP32 BLE Keyboard library for a list of key definitions to use as a reference.
Discussion