Inkplate 6MOTION - User buttons
The Inkplate 6MOTION features three onboard buttons that can be used for user interaction or to wake the device from deep sleep. These buttons are:
- USER1 (
INKPLATE_USER1) - USER2 (
INKPLATE_USER2) - WAKE (
INKPLATE_WAKE)
The WAKE button has a special function: it can wake Inkplate 6MOTION from deep sleep. See here for more info on waking via WAKE button.
Configuration
The buttons need to be configured as input pull-ups, meaning they are normally HIGH and go LOW when pressed:
// Configure button pin modes
pinMode(INKPLATE_USER1, INPUT_PULLUP);
pinMode(INKPLATE_USER2, INPUT_PULLUP);
pinMode(INKPLATE_WAKE, INPUT_PULLUP);
Reading button presses
A simple way to detect button presses is using digitalRead(). The example below waits for a button press and identifies which button was pressed by returning an integer:
int getButtonPress() {
// Wait for button press and return which button was pressed accordingly
while (true) {
if (digitalRead(INKPLATE_USER1) == LOW)
return 1;
if (digitalRead(INKPLATE_USER2) == LOW)
return 2;
if (digitalRead(INKPLATE_WAKE) == LOW)
return 3;
delay(5); // Short debounce delay
}
}
Full example
For an all-in-one demonstration, the Inkplate Motion library provides an example:
Inkplate_6_MOTION_Buttons.ino
Full example with pressing buttons and printing out which one was pressed