🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Lesson 4.2.1. IO Ports. The brightness of the fire

    Lessons and Guides
    2
    3
    13.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DimiD
      Dimi
      last edited by Dimi

      Step 1. Go to the folder Arduino-ESP32-IDE and open the app arduino.exe (Fig. 1);

      alt text
      Figure 1. The archive with the Arduino IDE extracted to the folder

      Step 2. Select New on the File menu, (Fig. 1.1);

      alt text
      Figure 1.1. Create a new sketch

      Step 3. Select Include Library, M5Stack in the Sketch menu, (Fig. 1.2);

      alt text
      Figure 1.2. Connection library M5Stack

      alt text
      Figure 2. The view from the top. Bus connector input/output

      alt text
      Figure 2.1. The view from the back side. Stickers with captions ports

      Step 4. Add to the beginning of system functions void setup() function call M5.begin();
      Please note that the Arduino IDE does not support the standard functions for working with analog ports of the microcontroller ESP32.
      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);

      alt text
      Figure 2.2 an example of the Correct preparation of the sketch

      Step 5. To work with PWM port (Fig. 2, 2.1) you can use the functions from list 1.

      List 1. Analog functions for ESP32

      • list itemledcSetup(uint8_t c, uint8_t f, uint8_t r); Sets the number of the channel c, frequency f (Hz) and resolution r (8 bits) for PWM
      • ledcAttachPin(uint8_t p, uint8_t c); Assigns the contact p to the channel c
      • ledcWrite(uint8_t C, uint8_t d); Sets the value of the filling signal d on channel c
      • ledcRead(uint8_t c); Gets the value of the PWM signal of the c channel

      Step 7. Write a brightness controller for led (Fig. 3);

      alt text
      Figure 3. Code brightness controller for LEDs

      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);

      alt text
      Figure 4. The led, resistor and M5Stack

      alt text
      Figure 4.1. Cable

      Step 7. Build the scheme according to figure 5;

      alt text
      Figure 5. Connect the led 21 to the contact

      Step 8. Click the Upload button (Fig. 6) to flash the device;

      alt text
      Figure 6. Download the firmware to the device

      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) :)

      alt text
      Figure 7. Increasing the brightness of the led with the button A

      alt text
      Figure 7.1. Decrease the brightness of the led with the button B

      1 Reply Last reply Reply Quote 0
      • Z
        zuobiao
        last edited by

        Thanks Dimi!
        Just a little remark: I can not see any figure of this lesson, Could you please check it?

        DimiD 1 Reply Last reply Reply Quote 0
        • DimiD
          Dimi @zuobiao
          last edited by

          @zuobiao thank you! I'm working on a story, photos will be added soon

          1 Reply Last reply Reply Quote 0
          • First post
            Last post