pdf-icon

Arduino Quick Start

2. Devices & Examples

CoreS3 Button

CoreS3 button input related APIs and case programs.

Note:
Include CoreS3.update() function in the main loop to read status update and minimize blocking, otherwise you may not be able to retrieve the status of key changes in time.

Example

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include <M5CoreS3.h>
void setup(void)
{
auto cfg = M5.config();
CoreS3.begin(cfg);
CoreS3.Display.setTextColor(RED);
CoreS3.Display.setTextDatum(middle_center);
CoreS3.Display.setFont(&fonts::Orbitron_Light_24);
CoreS3.Display.setTextSize(1);
CoreS3.Display.drawString("Touch Button Test", CoreS3.Display.width() / 2, 15);
}
void loop(void)
{
CoreS3.update();
if (CoreS3.BtnPWR.wasClicked()) {
CoreS3.Display.fillRect(0, 40, CoreS3.Display.width(), 70, BLACK);
CoreS3.Display.drawString("Btn PWR", CoreS3.Display.width() / 2, CoreS3.Display.height() / 2 - 30);
}
}

API

The status reading of the physical button (BtnPWR) on CoreS3 depends on the power management chip. Currently, only "wasClicked" and "wasHold" can be used normally.

On This Page
Example
API
Q&A
Submit a question
Select question category*
Arduino
MicroPython
UIFlow1
UIFlow2
EzData
M5Burner
Software
Hardware
Other
Product name
Product version
Question description*
(Supports pasting screenshots.)
Attachments
Add Files
Email*
Submit
OK

M5Stack Support

Hi, this is M5Stack Support. How can I help you today?