Learn

Blink an LED on a Raspberry Pi 4B — Your First GPIO Circuit

Wire an LED and resistor to a Raspberry Pi 4B GPIO pin and control it with Python — the simplest possible first circuit, and the foundation every other GPIO project builds on.

Try this directly in the free Raspberry Pi 4B simulator — no hardware or signup required. New to the GPIO header? Start with the interactive pinout guide.

What you’ll need

Step by step

  1. Open the Raspberry Pi 4B simulator — no signup needed to try it.
  2. Drag a Raspberry Pi 4B, an LED, and a resistor onto the canvas.
  3. Wire GPIO pin 37 → through the resistor → to the LED's anode (+).
  4. Wire the LED's cathode (−) → to a GND pin. The resistor limits the current flowing through the LED, and the GPIO pin controls whether it's on or off.
  5. Go to the Code tab and write:
import RPi.GPIO as GPIO
import asyncio
 
GPIO.setmode(GPIO.BOARD)
GPIO.setup(37, GPIO.OUT)
 
GPIO.output(37, GPIO.HIGH)
await asyncio.sleep(1)
 
GPIO.output(37, GPIO.LOW)
GPIO.cleanup()
  1. Click Start. When GPIO pin 37 is set to HIGH, the simulated LED turns on; when it's set to LOW, it turns off — the same fundamental GPIO concept you'd use to control an LED on a physical Raspberry Pi.

What “working correctly” looks like

If something’s wrong

More component tutorials are in Learn.