Fareed Mohmed ← Engineering

Fareed Mohmed · Engineering

Raspberry Pi Simulator

Real Python · Virtual Pi · 18 projects

Learn to program a Raspberry Pi without owning one. Pick a project, read the code, press Run, and watch LEDs, buttons, sensors, a servo and a motor react on a virtual board. The code is real Python using the same gpiozero and RPi.GPIO libraries you use on a real Pi, so it runs on a real Pi without changes. Edit the code, break it, fix it, and learn by doing.

This is a learning tool. Timing in the browser is approximate and some real-world effects (electrical noise, contact bounce, supply problems) are not simulated. Always check the wiring and the part data sheets before you connect real hardware. Never connect more than 3.3 V to a GPIO pin.

01

Pick a project and run it

Choose a project, press Run, and use the parts on the board. Click and hold the button, wave a hand at the sensor, or move a slider. Press Ctrl+Enter to run from the editor. The first run downloads Python once (about 10 MB).

Ready
Console ·

Wires are colour coded: red 5 V, orange 3.3 V, black GND, other colours are signals. The table below lists every connection.

Wiring for this project

02

The GPIO pins in two minutes

The 40-pin header is how a Raspberry Pi talks to the world. Most pins are general purpose inputs and outputs (GPIO). A few give power, and a few have special jobs.

Two numbering systems

Code uses the GPIO number (BCM), for example GPIO17. The pin position on the header is called the physical pin, and GPIO17 sits at physical pin 11. The simulator tables show both. Use GPIO numbers in code unless a tutorial says otherwise.

3.3 V logic, small current

Every GPIO pin works at 3.3 V and can give only a few milliamps. Never connect 5 V to a GPIO pin. Drive motors, relays and buzzers through a transistor or a driver board, and give LEDs a resistor.

Special jobs

GPIO2 and 3 are I2C, GPIO14 and 15 are the serial port, GPIO9, 10, 11 and 8 are SPI, and GPIO12, 13, 18 and 19 can make hardware PWM. Use the other pins first while you learn.

03

gpiozero cheat sheet

gpiozero is the friendly library that comes with Raspberry Pi OS. Each part is an object, and you tell it what to do. These are the parts you meet in the 18 projects.

ObjectWhat it isUse it like this
LED(17)An LED on GPIO17led.on() led.off() led.toggle() led.blink()
PWMLED(18)An LED you can dimled.value = 0.5 led.pulse()
Buzzer(18)An active buzzerbuzzer.on() buzzer.off() buzzer.beep(0.2, 0.2)
Button(27)A pushbutton to GNDbutton.is_pressed button.when_pressed = fn button.wait_for_press()
MotionSensor(4)A PIR sensorpir.motion_detected pir.wait_for_motion()
DistanceSensor(echo=24, trigger=23)An HC-SR04 ultrasonic sensorsensor.distance in metres, sensor.in_range
LightSensor(4)An LDR with a capacitorldr.value from 0 to 1, ldr.when_dark = fn
MCP3008(channel=0)An 8-channel analog to digital chipadc.value from 0 to 1, adc.voltage
AngularServo(17)A hobby servoservo.angle = 45
Motor(5, 6, enable=12)A DC motor on an H-bridgemotor.forward() motor.backward(0.5) motor.stop()
OutputDevice(17, active_high=False)Any on-off output, such as a relay board that switches ON when the pin is LOWrelay.on() relay.off() relay.toggle() relay.value
LEDBarGraph(5, 6, 13, 19, 26)Several LEDs as a barbar.value = 0.6

The older RPi.GPIO library works too. Projects 1, 2, 3 and 7 have an RPi.GPIO version: choose it above the editor.

04

From the simulator to a real Pi

The same code runs on a real board. Wire it, copy it, run it.

1 · Set up the Pi

Write Raspberry Pi OS to a card with Raspberry Pi Imager and boot the board. Python, Thonny (the editor) and gpiozero are already installed.

2 · Wire with the power off

Use the wiring table on this page. Fit the resistors. Check every wire against the pin position before you power the Pi, and never connect 5 V to a GPIO pin.

3 · Paste and run

Open Thonny, paste the code, press Run. Press Stop to end it. For the temperature project, switch on SPI first (sudo raspi-config, Interface Options).

What the simulator does not do

Mains safety

The home automation projects switch lamps, fans and pumps through a relay. Real mains wiring (120 V or 230 V) can kill. Practise with low-voltage loads, use rated relay modules in an enclosure, and have a qualified electrician do any mains work.

Not simulated

Camera, displays, I2C and UART devices, networking, files, and the Pi operating system. Only the parts shown in the 18 projects exist.

Python differences

Programs run one at a time. Threads and multiprocessing are not supported. Code that waits (sleep, wait_for_press, pause) is handled for you, so the page never freezes.

Timing and noise

Timing follows your browser clock and is only approximate. Real sensors give noisy values, real buttons bounce, and real motors and servos need their own supply. Treat the simulator as practice, not a test of your circuit.

05

User manual

What this page is for

It lets you learn Raspberry Pi programming without a board. You write and run real Python, and a virtual Pi shows what the pins, LEDs, sensors and motors would do. It is written for students, interns and engineers who are new to the Pi.

How to use it
  1. Pick a project in section 01.
  2. Read the code and the wiring table. Each coloured wire on the board goes from a GPIO pin to a part.
  3. Press Run or Ctrl+Enter. The first run loads Python (about 10 MB, once).
  4. Use the parts: click and hold a button, click the PIR dome, move a slider.
  5. Press Stop. Change the code and run it again. Use Reset code to go back.
Buttons, sliders and keys
  • Click and hold a button on the board. Shift-click latches it down until you click again.
  • Click the PIR dome to wave a hand for about 3 seconds.
  • Sliders set the distance, light and temperature.
  • Space or Enter also press a focused button.
  • Sound on or off switches the buzzer sound.
Errors and the console

Print output and error messages appear in the console below the editor. An error shows its type and the line number. When a program ends by itself, gpiozero switches every output off, which is the same as on a real Pi. Add pause() at the end to keep it running.

Limits

Only the parts in the 18 projects exist. Threads, camera, I2C displays and networking are not simulated. Timing follows the browser clock. This is practice, not proof that a circuit is correct. Check real wiring against the data sheets and never put more than 3.3 V on a GPIO pin.

What's new
  • v2 · 24 Oct 2026
    Added a Home automation group with six projects (relay wall switch, automatic porch light, thermostat fan, plant watering, smart door lock, home alarm) and a relay and soil-probe part.
  • v1 · 24 Oct 2026
    First release: 12 beginner projects (LED blink, button, traffic light, door alarm, PIR alarm, distance meter, PWM dimmer, servo, DC motor, temperature alarm, night lamp, reaction game) with real Python running in the browser, a virtual Pi board, a pinout, a gpiozero cheat sheet and RPi.GPIO versions of four projects.