Lesson 4.2. IO Ports. Switch fire
-
Step 1. Go to the folder Arduino-ESP32-IDE and open the app arduino.exe (Fig. 1);

Figure 1. The archive with the Arduino IDE is extracted to the folderStep 2. Select New on the File menu (Fig. 1.1);

Figure 1.1. Create a new sketchStep 3. Select Include Library, M5Stack in the Sketch menu (Fig. 1.2);

Figure 1.2. Connection library M5Stack
Figure 2. The view from the top. Bus connector input/output
Figure 2.1. The view from the back side. Stickers with captions portsStep 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);
Figure 2.2 an example of the Correct preparation of the sketchStep 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);

Figure 3. Code breaker for the ledStep 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);

Figure 4. The led, resistor and M5Stack
Figure 4.1. CableStep 7. Build the scheme according to figure 5;

Figure 5. Connect the led 21 to the contactStep 8. Click the Upload button (Fig. 6) to flash the device;

Figure 6. Download the firmware to the deviceStep 9. When the device firmware is completed, press the A button and watch the led (Fig. 7) :)

Figure 7. The control led on the digital port using the built-in buttons
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