SunFounder ESP32 Starter Kit
4. Finally, click “Run Current Script” or press F5 to execute it.
5. After the code runs, you will see the LED blinking.
How it works?
1. It imports two modules, machine and time. The machine module provides low-level access to the microcon-
troller’s hardware, while the time module provides functions for time-related operations.
import machine
import time
2. Then set up the pin26 as an output pin using the machine.Pin() function with the machine.Pin.OUT argument.
led = machine.Pin(26, machine.Pin.OUT)
3. In the While True loop, the LED is turned on for one second by setting the value of the pin26 to 1 using
led.value(1) and then set to 0(led.value(0)) to turn it off for one second, and so on in an infinite loop.
310 Chapter 3. For MicroPython User