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

    Lesson 4.2. IO Ports. Switch fire

    Scheduled Pinned Locked Moved Lessons and Guides
    1 Posts 1 Posters 9.0k Views 1 Watching
    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 Offline
      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 is 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();
      Next, set the working mode of the port to input (INPUT) or output (OUTPUT) data, by calling functions pinMode(nomernogo, OUTPUT); You can use an integer variable as the contact number.
      Add to the end system functions void loop() function call M5.update (); it 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 digital port you can use the standard functions Digital I/O in the Arduino IDE, which is available in list1 and the link

      List 1. Functions for working with digital port

      • digitalRead(uint8_t pin); Retrieves a Boolean value of the digital signal on port pin
      • digitalWrite(uint8_t pin, uint8_t value); Sets the logical value of the signal value to a digital port pin
      • pinMode(uint8_t pin, uint8_t dir); Sets the operating mode of the port pin to input or output data dir

      Step 7. Write a simple switch to led (Fig. 3);

      alt text
      Figure 3. Code breaker for the led

      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 and watch the led (Fig. 7) :)

      alt text
      Figure 7. The control led on the digital port using the built-in buttons

      1 Reply Last reply Reply Quote 0

      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
      • First post
        Last post