<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Lesson 2. BUTTONS. Menu]]></title><description><![CDATA[<p dir="auto"><strong>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.</strong></p>
<p dir="auto"><strong>Step 1. Review the functions buttons (Fig. 1) in list 1;</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c621706/v621706804/465ac/hW1stp6uM-U.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 1. Built-in button</p>
<p dir="auto">List 1. Functions for working with built-in buttons</p>
<ul>
<li>M5.BtnA/B/C. read(); Constantly returns true if the button is pressed and false if pressed</li>
<li>M5.BtnA/B/C. isPressed(); If the button was pressed – always returns true</li>
<li>M5.BtnA/B/C. isReleased(); If the button is pressed – always returns true</li>
<li>M5.BtnA/B/C. wasPressed(); One press – one true</li>
<li>M5.BtnA/B/C. was released(); One UPS – single true</li>
<li>M5.BtnA/B/C. pressedFor(uint32_t ms); If the button is pressed more than the set time – always returns true</li>
<li>M5.BtnA/B/C. releasedFor(uint32_t ms); If the button is pressed more than the set time – always returns true</li>
<li>M5.BtnA/B/C. lastChange(); Constantly returns true if the button has ever been pressed</li>
</ul>
<p dir="auto"><strong>Step 2. Create a new sketch in the Arduino IDE. On the File menu, select New (Fig. 2);</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c621706/v621706804/465b3/TmBg5JFoMKk.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 2. Create a new sketch</p>
<p dir="auto"><strong>Step 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);</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c621706/v621706804/465bc/PAgOn75OYb8.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 3. The sketch</p>
<p dir="auto"><strong>Step 4. Click the Upload button (Fig. 4) in order to flash the device;</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c621706/v621706804/465c3/-GsKxmeSqD4.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 4. Download the firmware to the device</p>
<p dir="auto"><strong>Step 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).</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c621706/v621706804/465e1/tBSeh56qIb4.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 5. After pressing the red button</p>
<p dir="auto"><img src="https://pp.userapi.com/c621706/v621706804/465cd/KyObvopdRwM.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 5.1. After clicking on the green button</p>
<p dir="auto"><img src="https://pp.userapi.com/c621706/v621706804/465d7/_tsN9v8jLi4.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 5.2. After clicking on the blue button</p>
]]></description><link>https://community.m5stack.com/topic/42/lesson-2-buttons-menu</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 17:47:03 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/42.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 07 Dec 2017 06:36:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Lesson 2. BUTTONS. Menu on Tue, 17 Sep 2024 15:34:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dimi" aria-label="Profile: Dimi">@<bdi>Dimi</bdi></a> The information in step 1 is incorrect.</p>
]]></description><link>https://community.m5stack.com/post/26452</link><guid isPermaLink="true">https://community.m5stack.com/post/26452</guid><dc:creator><![CDATA[MichaelKlos]]></dc:creator><pubDate>Tue, 17 Sep 2024 15:34:24 GMT</pubDate></item></channel></rss>