science tinker

Microcontroller simulator

A free browser simulator for the Arduino Uno, Nano and Mega 2560, ESP32, BBC micro:bit, ATtiny85, the Raspberry Pi 4, 5 and Zero 2 W and the Raspberry Pi Pico, Pico W, Pico 2 and Pico 2 W, built around a real breadboard with 138 parts. Wire parts hole by hole, then program them with drag-and-drop blocks, standard Arduino C++, or Python and MicroPython on the Raspberry Pi boards. The simulator solves the circuit (currents, voltage drops, LED forward voltage) and runs your code the way the real chip does: a 16-bit int on the Uno, whole-number division, and sensors that only answer when you use them correctly. So a missing resistor, a backwards part or an overflow shows up here before it costs you a component. 85 guided projects check both the wiring and the code. Nothing to install, no account needed.

Your work saves on this device. Sign in to keep it on every device you use.

🗂 My projects🖼 Project gallery🎓 Take the tour
Wire100%
Wires: click a pin or hole, click between holes to add straight corners, then click right on a hole to finish (or just drag from hole to hole) · tap a wire, then drag a straight part to slide it, drag a white dot to move a corner, double-click to add or remove a corner, drag a blue end to re-plug · drag a part to move it · pinch or Ctrl + scroll to zoom
⏱ 00:00:00
Serial Monitor 9600 baud
Variables live values
Pin timeline like a logic analyser: every pin over time
Your circuit and code are saved in this browser automatically. Tip: Ctrl + Enter runs the code.

Components for this project

Every part in this build: its function in this project, how it works, what it is made of (down to the elements and the rocks they are mined from), its chemistry, and the biology it mirrors. Tap a part to open it.

📚 Open the full Electronic Components Atlas

What a microcontroller is

A microcontroller is a tiny, complete computer on a single chip, made to control one device. A laptop is a general-purpose computer that runs many programs for a person sitting at it. A microcontroller is the opposite: small, cheap, and built into a product to do one job over and over. It has a processor to carry out instructions, memory to hold its program, and rows of pins that connect it to the outside world. Through its input pins it reads sensors and buttons. Through its output pins it switches lights, motors and buzzers. There are microcontrollers in washing machines, microwave ovens, remote controls, cars, toys and thermostats, usually several in each. To make them easy to learn and to use, a microcontroller is mounted on a development board, such as the Arduino Uno, the ESP32 or the BBC micro:bit, with a USB socket and labelled pins. This simulator gives you those boards, a breadboard and 129 parts, so you can wire a circuit and program it without buying anything.

What a microcontroller is for

  • Learning electronics and coding together. A program makes something real happen: a light, a sound, a movement.
  • Testing before you build. Find a wiring mistake here before it costs you a component.
  • School and hobby projects. Alarms, weather stations, robots and games.
  • Control and automation. Read a sensor, make a decision, drive an output.
  • Engineering courses. Embedded systems are a core part of computer and electronics engineering.

How it works

Pins. A digital pin has two states: HIGH (5 V on an Uno) or LOW (0 V). In a program, pinMode sets a pin as an input or an output, digitalWrite sets an output HIGH or LOW, and digitalRead reads an input. An analog input pin measures a voltage anywhere between 0 V and 5 V. analogRead gives a whole number from 0 to 1023, so voltage = reading × 5 ÷ 1023. A pin can supply only a small current, about 20 mA, which is why an LED needs a series resistor and a motor needs a driver.

The program, called a sketch, has two parts. setup() runs once when the board starts. loop() then runs again and again for ever. delay(500) makes the board wait 500 milliseconds. PWM (pulse-width modulation) switches a pin on and off very fast, and the fraction of the time it is on sets the average power, which dims an LED or changes a motor’s speed. The Serial Monitor shows text that the board sends back, and is the main way to find mistakes.

The breadboard. The holes in each short row of five are joined together inside. The long rails down the sides carry power (+) and ground (−). A part’s legs go in different rows, and wires join rows to the board’s pins. This is a simulator: it solves the circuit for its currents and voltages and runs your code the way the real chip does, with a 16-bit int on the Uno, whole-number division, and parts that burn out if they are wired wrongly.

How to use this simulator

  1. Pick a project from the Project list, starting with 1. Blink, or choose Free build. Press Read the full brief.
  2. Tap a part in the parts bin to add it, and drag it into the holes of the breadboard. Drag from one hole or pin to another to make a wire.
  3. Write the code as ⌨ Text, as 🧩 Blocks, or with both side by side.
  4. Press ▶ Run simulation. Watch the circuit, the Serial Monitor and the live Variables. Press ■ Stop to end.
  5. Use ⏭ Step to run one line at a time, slow motion to watch closely, and 📐 Schematic diagram to see the circuit drawn with symbols.
  6. Press ✔ Check my project. It tests the wiring and the code and tells you what to fix. Press 🖥️ Open in Studio for the full window.

Worked example

Question. A red LED with a forward voltage of 2.0 V is connected to a 5 V pin through a 220 Ω resistor. What current flows, and is it safe for the pin? Then: analogRead on a potentiometer gives 614. What voltage is on the pin?

  1. Voltage across the resistor: 5.0 − 2.0 = 3.0 V.
  2. Current: I = V ÷ R = 3.0 ÷ 220 = 0.0136 A, or about 13.6 mA.
  3. A pin on an Uno can safely supply about 20 mA, so 13.6 mA is safe.
  4. Analog reading: voltage = reading × 5 ÷ 1023.
  5. Voltage = 614 × 5 ÷ 1023 = 3.00 V.

Answer. About 13.6 mA flows through the LED, which is within the limit of the pin. A reading of 614 means 3.00 V on the analog pin.

Common mistakes

  • Connecting an LED to a pin with no resistor.Add a series resistor, such as 220 Ω, or the LED and the pin can be damaged.
  • Forgetting pinMode.Set each pin as INPUT or OUTPUT in setup() before you use it.
  • Putting both legs of a part in the same row.A row joins its five holes, so the part is short-circuited. Put each leg in a different row.
  • Leaving an input pin connected to nothing.A floating pin reads random values. Use a pull-up or pull-down resistor, or INPUT_PULLUP.
  • Expecting an int to hold any number.On an Uno an int holds −32,768 to 32,767. Beyond that it overflows. Use long for larger values.

Key words

Program
A list of instructions that a computer carries out.
Loop
A part of a program that repeats a set of instructions.
LED
A light-emitting diode: a component that gives out light when current flows through it in one direction.
Resistor
A component made to have a fixed resistance.
Current
The rate of flow of electric charge, in amperes (A).
Voltage
The push that drives electric charge round a circuit, measured in volts (V).
Ground
The point in a circuit taken as zero volts, from which other voltages are measured.
Microcontroller
A small, complete computer on one chip, with a processor, memory and input and output pins.
Development board
A circuit board that holds a microcontroller with a USB socket and labelled pins, such as the Arduino Uno.
Pin (of a microcontroller)
A metal contact on a chip or board through which it reads an input or drives an output.
Sketch
The Arduino name for a program.
Breadboard
A board with rows of joined holes for building a circuit without soldering.
Digital signal
A signal that has only two states, HIGH and LOW.
Analog signal
A signal that can take any value in a range.
Pulse-width modulation
Switching a pin on and off quickly so that the fraction of time it is on sets the average power (PWM).
Sensor
A component that measures something, such as light or temperature, and turns it into an electrical signal.

See every key word in the glossary

What to learn first and next

Learn this first
Learn this next

What makes this simulator different

  • Real breadboard wiring. Parts plug into real holes, and you wire them yourself. The simulator follows the metal strips inside the breadboard to work out what is connected, so a wrong hole really does break the circuit, just like in real life.
  • Wiring help in plain English. “The LED is backwards”, “No resistor: a real LED would burn out”, “Connect the brown servo wire to GND”, “Both legs are in the same row, so the LED is shorted out”.
  • Step through your code. Run one line at a time or in slow motion, with the current line highlighted.
  • See every pin over time. The pin timeline works like a logic analyser: blinks, PWM duty cycles, servo angles and buzzer tones.
  • Missions that check your wiring and your code. The checker presses the buttons, turns the knob and moves objects for you, then explains what still needs fixing.
  • A step-by-step build list. Open How to build this on a real breadboard to copy your circuit, hole by hole, onto a real one.
  • Free, with no account, and it works on a phone (pinch to zoom). Share your project with a link.

Basic electronics: batteries, switches and a multimeter

You don’t need code to start. Add a 9 V battery, an AA battery, a 2 × AA or 4 × AA pack, a coin cell or a Li-ion 18650, wire its red (+) and black (−) leads to the breadboard, and the circuit runs straight away. A real circuit solver works out the voltage at every point and the current in every part, so a 220 Ω resistor and an LED on a 9 V battery take about 30 mA, a light bulb glows brighter on 6 V than on 3 V, a DC motor spins faster with more current (and backwards if you swap its leads), and a capacitor charges and discharges slowly through a resistor. A slide switch connects its middle leg to one side or the other: tap it to flip. A diode lets current through in one direction only. An NPN transistor (2N2222) lets a small current into its base switch a big current through its collector, which is how an Arduino pin safely controls a motor. Use the multimeter to measure: touch its probes across a part to read volts, or tap it to switch to mA and put it in the path of the current. If something would get hot or break in real life (a shorted battery, an LED with no resistor, a motor straight on a pin), the simulator warns you and explains why.

Laying out wires neatly

Click a pin or a hole to start a wire, click anywhere between holes to add a corner (the wire stays straight and lines up with the hole rows), and click right on a hole to finish. To tidy a wire later, tap it, then drag any straight section to slide it, drag a white dot to move a corner, double-click to add or remove a corner, or drag a blue end square to plug it into another hole.

ESP32: Wi-Fi and a phone dashboard

The ESP32 is a microcontroller with Wi-Fi and Bluetooth built in, used in smart-home gadgets and IoT projects. Its pins work at 3.3 V (not 5 V), its analog inputs read 0–4095 (12-bit), almost every pin can do PWM, and GPIO 34, 35, 36 and 39 are input-only. The blue LED on the board is on GPIO 2. In the simulator, WiFi.begin() joins a virtual network and the WebServer library works as on a real board: open your page on the virtual 📱 phone next to the code, tap its links and buttons, and the ESP32 answers in server.handleClient(). Use the ADC1 pins (GPIO 32–39) for analog sensors in Wi-Fi projects, because ADC2 stops working while Wi-Fi is on.

The MPU6050 accelerometer and the earthquake alarm

The MPU6050 (GY-521 board) measures acceleration on three axes and rotation, and talks to the microcontroller over I²C with just two signal wires: SDA (data) and SCL (clock), on GPIO 21 and 22 on the ESP32, or A4 and A5 on the Uno. When it is still it measures gravity, about 9.81 m/s² straight down. To detect shaking, measure the resting value of each axis first, then watch how far the readings move away from it: shake = √(dx² + dy² + dz²). Use the Shake slider for everyday vibration and 🌋 Earthquake! for a real quake, with a weak P-wave first and the strong S-wave about two seconds later. A good alarm ignores a passing truck but reacts to the quake, which is exactly the problem every earthquake early-warning sensor has to solve.

How a breadboard is connected

Inside a breadboard, the five holes in each short column (a–e, or f–j) are joined by a metal strip, so anything plugged into the same column half is connected. Hover over (or touch) a hole to see which holes it is connected to. The gap down the middle separates the two halves, which is why a push button or a chip straddles it. The long rows along the edges, marked + and −, are the power rails: wire the Arduino’s 5V to + and GND to −.

The Arduino Uno R3

Pins 0–13 are digital: each can be an OUTPUT (0 V or 5 V) or an INPUT. Pins marked ~ (3, 5, 6, 9, 10 and 11) can also do PWM: analogWrite(pin, 0–255) switches the pin on and off about 490 times a second, so the average voltage, and an LED’s brightness, can be set in 256 steps. Pins A0–A5 read voltages from 0 to 5 V with analogRead, giving a number from 0 to 1023 (about 4.9 mV per step). The POWER header has 5V, 3.3V, two GND pins and Vin; there is one more GND next to pin 13. Pin 13 also drives the small built-in LED marked L, and pins 0 and 1 (RX and TX) are used by the USB serial connection.

Why an LED needs a resistor

An LED drops about 2 V, so on a 5 V pin the remaining 3 V must be taken up by a resistor: R = (5 − 2) ÷ 0.015 A ≈ 200 Ω, so the standard 220 Ω is used. Try a 1 kΩ or 10 kΩ resistor in the simulator and watch the LED get dimmer, because less current flows (I = V ÷ R).

Buttons and INPUT_PULLUP

An input pin with nothing connected “floats” and reads random 0s and 1s. With pinMode(pin, INPUT_PULLUP), a resistor of about 20–50 kΩ inside the chip pulls the pin up to 5 V, so it reads HIGH. Wire the button between the pin and GND: pressing it connects the pin to 0 V, so it reads LOW.

Measuring distance with sound

The HC-SR04 sends a burst of ultrasound when Trig goes HIGH for 10 µs, then holds Echo HIGH until the echo returns. Sound travels about 343 m/s, or 0.034 cm per microsecond, and has to go there and back, so distance (cm) = time (µs) × 0.034 ÷ 2, about time ÷ 58.

Questions students ask

Is this the same as a real Arduino?

Your code is the same C++ you would upload with the Arduino IDE, the board has the real Uno pin layout, and the breadboard is connected like a real one. The simulator understands the common Arduino language (pinMode, digitalWrite, analogRead, delay, millis, Serial, Servo, tone, pulseIn, arrays and your own functions). Advanced C++ such as classes, pointers and most libraries is not supported.

How is this different from Tinkercad Circuits?

It adds step-by-step and slow-motion code execution with the current line highlighted, a live variable watch, a pin timeline like a logic analyser, missions that check both your wiring and your code automatically, plain-English wiring and code errors, and a hole-by-hole build list for a real breadboard. It opens instantly on a phone with no account.

Can I build a circuit with just a battery, no Arduino?

Yes. Add a battery from the parts bin (9 V, AA, 2 × AA, 4 × AA, coin cell or Li-ion), a resistor and an LED, a bulb or a motor, and wire them in a loop from + back to −. No code is needed: press Run to switch the power on, as in Tinkercad, and Stop to switch it off and change the wiring. Add a slide switch to turn it on and off, and a multimeter to measure volts and milliamps.

How do I change the temperature a TMP36 sensor reads?

Press Run. A slider appears above the TMP36 with a cold thermometer on the left and a hot one on the right. Drag the dark knob to set any temperature from −40 °C to 125 °C (the sensor's real range); the knob shows the value and your sketch reads it at once. The slider in the parts list does the same.

How do I change what a sensor measures, such as light, moisture, force or gas?

Press Run. A measurement slider appears above every sensor, with a picture for "less" on the left and "more" on the right, and a dark knob that shows the value in the sensor's own unit: lux for the photoresistor (LDR), photodiode and ambient light sensor, W/m² for the solar cell, degrees of bend for the flex sensor, newtons for the force sensor, percent for soil moisture, ppm for the gas sensor and g for the MPU6050. The tilt, PIR motion and line sensors get a two-position slider (upright or tilted, still or motion, white or black). Drag the knob or click the track and your sketch reads the new value at once.

How do I change the distance an ultrasonic sensor measures?

Press Run. A green cone appears in front of the HC-SR04 or 3-pin sensor, with a teal object and two dashed lines from the sensor to it. Drag the object nearer or farther (2 to 300 cm) and the label shows the distance in inches and centimetres, just like Tinkercad. The slider in the parts list does the same.

How do I make my wires bend like in Tinkercad?

While drawing a wire, click between the holes to add corners and click right on a hole to finish. After a wire is placed, tap it and drag any straight part sideways, drag the white dots to move corners, or double-click to add or remove a corner.

Why is my LED not lighting up?

Check the list under the breadboard: it says what is wrong. Usually the short leg (−) is not connected to GND, the LED is backwards (the long leg must face the pin), or the resistor and the LED are not in the same row of holes.

Why does my button read random values?

The pin is floating. Wire the button between the pin and GND and use pinMode(pin, INPUT_PULLUP); a press then reads LOW and a release reads HIGH.

What practice projects are there?

85 projects in three levels, each with a starter sketch, a hint, a solution and an automatic check of your wiring and code. Basic: Blink, SOS signal, Traffic light, Running lights, Button and LED, Potentiometer dimmer, Night light, Blink an LED in Python (Raspberry Pi), Button and LED in Python (Raspberry Pi), Message and timer on an LCD (Raspberry Pi), Button and LED with gpiozero (Raspberry Pi 5), Doorbell with a button and a buzzer (Pi Zero 2 W), Blink an LED in MicroPython (Pico), Traffic light in MicroPython (Pico 2). Intermediate: LED bar graph, Play a scale, On/off with one button, Temperature alarm, Colour picker, Potentiometer-controlled servo, Reaction timer, Servo with 4 buttons, Parking sensor, Dark-activated lamp (relay), Count 0–9 on a 7-segment display, Button counter, Mini piano, Laser with a safety button, Laser tripwire alarm, Laser beam people counter, Touch lamp, Magnet counter, Door alarm (reed switch), Clap switch, Water tank level, Flame alarm, Gas alarm (MQ-2), Tilt alarm, Motion light (PIR), Thirsty plant (soil moisture), NeoPixel colour cycle, Spinning NeoPixel ring, NeoPixel level meter, Remote-controlled lamp, Distance with one signal pin, Thermistor thermometer, Weather station (DHT11), Digital thermometer (DS18B20), Joystick pointer, Stepper quarter turns, Bluetooth lamp, RFID door lock, Tank alarm with two sensors (Raspberry Pi), RFID door lock in Python (Raspberry Pi), Dim an LED with a knob and an MCP3008 (Raspberry Pi 5), Digital thermometer with a DS18B20 (Raspberry Pi 5), Dim an LED with a knob in MicroPython (Pico), Voltmeter on an LCD (Pico 2). Advanced: Automatic door, Pedestrian crossing, Electronic dice, Fan thermostat (relay), LCD thermometer, Distance meter (LCD), Motor speed and direction, Gearmotor forward and back (L293D), LCD stopwatch, LCD progress bar, Smart bridge monitor, Keypad calculator, Electronic safe, Alarm clock, LED matrix tunnel, Line-following robot, Servo dance (32 servos), Simon memory game with score, Dino jump game, Phone-controlled LED (ESP32), Wi-Fi thermometer (ESP32), Earthquake alarm (ESP32), Stepper motor in Python (Raspberry Pi), Thermometer on an OLED display (Raspberry Pi 5), Thermometer on an OLED display (Pico), Phone-controlled LED, Knob on a web page.

Can I use an ESP32?

Yes. In Free build, add the ESP32 DevKit V1 from Components › Boards (or open the ESP32 missions). Wi-Fi, the WebServer library, analogRead on the ADC pins, analogWrite and ledcWrite, the Servo library and the MPU6050 (Adafruit_MPU6050 or MPU6050_light) all work, and a virtual phone opens the web pages your ESP32 serves.

Can I use a Raspberry Pi?

Yes. The simulator has the Raspberry Pi Pico, Pico W, Pico 2 and Pico 2 W, programmed in MicroPython (machine.Pin, PWM, ADC, and Wi-Fi on the W boards) or Arduino C++, the Raspberry Pi 4 Model B and the Raspberry Pi Zero 2 W, programmed in Python 3 with the RPi.GPIO or gpiozero library, and the Raspberry Pi 5, programmed with gpiozero (RPi.GPIO fails on it with the same error as on a real Pi 5). Add it from Components › Boards and the code panel changes to Python. GPIO.setmode(GPIO.BOARD) and GPIO.setmode(GPIO.BCM), GPIO.setup with pull-ups, GPIO.output, GPIO.input, PWM, edge detection, time.sleep and time.time all work, and Stop acts like Ctrl+C. Parts have Python libraries too: gpiozero MCP3008 for analog sensors, RPLCD for the LCD, w1thermsensor for the DS18B20 and mfrc522 for the RFID reader on the Raspberry Pi computers, and machine.I2C, ssd1306, pico_i2c_lcd, onewire and ds18x20 on the Pico boards. The pins are 3.3 V, so a 5 V signal such as the HC-SR04 Echo pin needs a voltage divider, and the simulator checks that it is there.

How do I add a part?

Drag it from the parts bin above the breadboard and drop it where you want it: its legs snap into the holes. Or tap a part to drop it in the next free space. Then wire it by clicking a pin and then a hole.

More engineering and electricity

Know someone who would use this?

It’s free for every learner. Send it to your class, team or club.

Updated · Free, no sign-up ·

Connected tools

The same idea from another angle, across the site.