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

  • Raspberry Pi 4B
  • LED
  • Resistor (~220Ω–330Ω to limit current)

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

  • The LED turns on immediately when the script starts, stays on for about a second, then turns off.
  • Nothing else on the board changes — this circuit only ever touches the one GPIO pin, the resistor, and the LED.

If something’s wrong

  • LED never lights → double-check the anode/cathode orientation; an LED only conducts one way.
  • Nothing happens at all → confirm GPIO pin 37 is wired through the resistor to the LED, not directly to power or left disconnected.