MicroPython blink on an ESP32
MicroPython on an ESP32 DevKit: machine.Pin blinks the board’s own LED on GPIO 2 and a red LED wired to D2, twice a second, and print() says on and off. The whole build, an ESP32 DevKit and 2 more parts, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.
Teaching? Assign it to your class in one click.
Beginner Runs in your browser. Free, and no account needed.
The parts retail for about $9.15. On Mokxi they're free.
The code
The MicroPython code exactly as the editor opens it. Change a line there and press Run: the board runs it on the official MicroPython firmware, with nothing to compile.
# MicroPython on an ESP32 DevKit: blink an LED.
# GPIO 2 is the DevKit's own blue LED, and the red LED wired to D2 through
# 220 ohms blinks with it.
from machine import Pin
import time
led = Pin(2, Pin.OUT)
while True:
led.value(1)
print("on")
time.sleep_ms(500)
led.value(0)
print("off")
time.sleep_ms(500)
Parts list
3 parts, plus the jumper wires. They retail for about $9.15; on Mokxi they're free.
- 1 × ESP32 DevKit V1
- 1 × Resistor, 220 Ω
- 1 × LED, red
How it is wired
3 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.
- ESP32 DevKit V1 pin D2; Resistor, 220 Ω pin 1
- Resistor, 220 Ω pin 2; LED, red pin A
- Ground: LED, red pin C
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.