
Arduino Quick Start
M5ChainDualKey.
M5Unified driver library and all required dependencies.
Move the switch to the middle position, hold Key1 (the button farther from the lanyard hole) and connect the device to your PC via a USB-C data cable. Then release Key1, and the device will enter download mode, allowing you to select the correct controller and device port in Arduino IDE.
#include <M5Unified.h>
m5::Button_Class Key1;
void setup() {
pinMode(0, INPUT);
Serial.begin(115200);
}
void loop() {
uint32_t ms = millis();
Key1.setRawState(ms, !digitalRead(0));
if (Key1.wasPressed()) {
Serial.println("Key1 was pressed");
}
delay(10);
}Copy the program above into Arduino IDE, click the Upload button, and once the compilation and upload are complete, open the Serial Monitor. When Key1 is pressed, the device will send a line of text to the serial monitor:
The Chain DualKey does not have a reset button. If the program does not run after uploading, move the switch to the middle position, disconnect the USB-C cable, and reconnect it (do not hold Key1) to reboot the device.
SWITCH_1 (G8) or SWITCH_2 (G7) as output high level; otherwise, the device will fail to properly power off.