Lesson 2. BUTTONS. Menu
-
This lesson focuses on the built-in buttons. We will learn how to use the buttons on the example of changing the color of the circle.
Step 1. Review the functions buttons (Fig. 1) in list 1;

Figure 1. Built-in buttonList 1. Functions for working with built-in buttons
- M5.BtnA/B/C. read(); Constantly returns true if the button is pressed and false if pressed
- M5.BtnA/B/C. isPressed(); If the button was pressed – always returns true
- M5.BtnA/B/C. isReleased(); If the button is pressed – always returns true
- M5.BtnA/B/C. wasPressed(); One press – one true
- M5.BtnA/B/C. was released(); One UPS – single true
- M5.BtnA/B/C. pressedFor(uint32_t ms); If the button is pressed more than the set time – always returns true
- M5.BtnA/B/C. releasedFor(uint32_t ms); If the button is pressed more than the set time – always returns true
- M5.BtnA/B/C. lastChange(); Constantly returns true if the button has ever been pressed
Step 2. Create a new sketch in the Arduino IDE. On the File menu, select New (Fig. 2);

Figure 2. Create a new sketchStep 3. Please note that for operation of the buttons you want to add to the end system functions void loop() function call M5.update(); Write our code (Fig. 3);

Figure 3. The sketchStep 4. Click the Upload button (Fig. 4) in order to flash the device;

Figure 4. Download the firmware to the deviceStep 5. When the device firmware is completed, the device display labels above the buttons with the corresponding colors are displayed a circle of different colors (Fig. 5 - 5.2).

Figure 5. After pressing the red button
Figure 5.1. After clicking on the green button
Figure 5.2. After clicking on the blue button -
@Dimi The information in step 1 is incorrect.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login