<?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 4.2.1. IO Ports. The brightness of the fire]]></title><description><![CDATA[<p dir="auto"><strong>Step 1. Go to the folder Arduino-ESP32-IDE and open the app arduino.exe (Fig. 1);</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60bd2/Z2jjn1mE71s.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 1. The archive with the Arduino IDE extracted to the folder</p>
<p dir="auto"><strong>Step 2. Select New on the File menu,  (Fig. 1.1);</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60bc1/hAWPy0gxtEc.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 1.1. Create a new sketch</p>
<p dir="auto"><strong>Step 3. Select Include Library, M5Stack in the Sketch menu,  (Fig. 1.2);</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60bc9/HaD4-8bgpkc.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 1.2. Connection library M5Stack</p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60bed/1DblKf_wESk.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 2. The view from the top. Bus connector input/output</p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60bdc/a035l8N3FHg.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 2.1. The view from the back side. Stickers with captions ports</p>
<p dir="auto"><strong>Step 4. Add to the beginning of system functions void setup() function call M5.begin();<br />
Please note that the Arduino IDE does not support the standard functions for working with analog ports of the microcontroller ESP32.<br />
Add to the end system functions void loop() function call M5.update (); is required for correct operation of the device with built-in buttons (Fig. 2.2);</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60be3/5oXwZjSqIUc.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 2.2 an example of the Correct preparation of the sketch</p>
<p dir="auto"><strong>Step 5. To work with PWM port (Fig. 2, 2.1) you can use the functions from list 1.</strong></p>
<p dir="auto">List 1. Analog functions for ESP32</p>
<ul>
<li><strong>list itemledcSetup(uint8_t c, uint8_t f, uint8_t r);</strong> Sets the number of the channel c, frequency f (Hz) and resolution r (8 bits) for PWM</li>
<li><strong>ledcAttachPin(uint8_t p, uint8_t c);</strong> Assigns the contact p to the channel c</li>
<li><strong>ledcWrite(uint8_t C, uint8_t d);</strong> Sets the value of the filling signal d on channel c</li>
<li><strong>ledcRead(uint8_t c);</strong> Gets the value of the PWM signal of the c channel</li>
</ul>
<p dir="auto"><strong>Step 7. Write a brightness controller for led (Fig. 3);</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60c37/tBqbXxpdURE.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 3. Code brightness controller for LEDs</p>
<p dir="auto"><strong>Step 6. Prepare the led To 5 V and a resistor of 100 Ω (figure 4) and the cable, which is included in the kit (Fig. 4.1);</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60c09/iyOeg2-xX7k.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 4. The led, resistor and M5Stack</p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60bff/-knVB3B1UqI.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 4.1. Cable</p>
<p dir="auto"><strong>Step 7. Build the scheme according to figure 5;</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60c13/SLfcvn9HJCU.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 5. Connect the led 21 to the contact</p>
<p dir="auto"><strong>Step 8. Click the Upload button (Fig. 6) to flash the device;</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60c1a/cIASGxQi3xc.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 6. Download the firmware to the device</p>
<p dir="auto"><strong>Step 9. When the device firmware is completed, press the A button to increase the brightness B to decrease brightness of the led (Fig. 7, 7.1) :)</strong></p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60c2e/jLw1HnqshC4.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 7. Increasing the brightness of the led with the button A</p>
<p dir="auto"><img src="https://pp.userapi.com/c639119/v639119464/60c24/F_ejBGrmFVE.jpg" alt="alt text" class=" img-fluid img-markdown" /><br />
Figure 7.1. Decrease the brightness of the led with the button B</p>
]]></description><link>https://community.m5stack.com/topic/51/lesson-4-2-1-io-ports-the-brightness-of-the-fire</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 08:40:38 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/51.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 13 Dec 2017 09:21:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Lesson 4.2.1. IO Ports. The brightness of the fire on Thu, 14 Dec 2017 06:01:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zuobiao" aria-label="Profile: zuobiao">@<bdi>zuobiao</bdi></a> thank you! I'm working on a story, photos will be added soon</p>
]]></description><link>https://community.m5stack.com/post/96</link><guid isPermaLink="true">https://community.m5stack.com/post/96</guid><dc:creator><![CDATA[Dimi]]></dc:creator><pubDate>Thu, 14 Dec 2017 06:01:42 GMT</pubDate></item><item><title><![CDATA[Reply to Lesson 4.2.1. IO Ports. The brightness of the fire on Wed, 13 Dec 2017 09:43:32 GMT]]></title><description><![CDATA[<p dir="auto">Thanks Dimi!<br />
Just a little remark: I can not see any figure of this lesson, Could you please check it?</p>
]]></description><link>https://community.m5stack.com/post/94</link><guid isPermaLink="true">https://community.m5stack.com/post/94</guid><dc:creator><![CDATA[zuobiao]]></dc:creator><pubDate>Wed, 13 Dec 2017 09:43:32 GMT</pubDate></item></channel></rss>