AVR101 Help: the AVR101 Simulator

How to use the simulator, from the first example to the multimeter. For the Arduino C commands it runs, see the AVR101 Reference. Back to the simulator.

AVR101 Simulator

The AVR101 Simulator (version 1.0.1) is an Arduino Uno with a real compiler. Your sketch is compiled by GCC (avr-gcc 7.3.0, the compiler the Arduino IDE uses for the Uno) in your own browser, and the machine code runs on a simulated ATmega328P (avr8js), instruction by instruction, as on a real Uno. A sketch that the Arduino IDE compiles for the Uno compiles here too, as long as it uses only the Wire, SPI, and Servo libraries: functions in any order, several files, attachInterrupt(), String, EEPROM, and all of C++ that avr-gcc compiles.

The bench is the Uno Breadboard Simulator's (UB90, on the Robotics page): an Arduino Uno, one long breadboard, a power supply with four buses, a multimeter, an oscilloscope, an Electronics Lab with its modules, and an ATmega328P you can place on the breadboard, which runs its own sketch on its own simulated chip. The Uno and that chip talk through the wires, by Serial, I2C, or SPI, as two real chips do.

AVR101 is in development and is tested often; it will replace UB90 once it is fully functional.

Quick Start

  1. The page opens with Blink: an LED on pin 13 through 220 Ω, wired under the Uno.
  2. Press Upload (the right arrow). The first time in a visit, the page loads the compiler (about 13 MB, a few seconds). Then it compiles the sketch, loads it onto the Uno, and starts it. The LED blinks once a second.
  3. Press Examples and choose another sketch. Leave Wire it for me checked: the example's circuit is placed on the breadboard under the Uno, and its modules in the lab.
  4. Watch the LEDs on the breadboard and the text in the Serial Monitor.
  5. Change the code and press Upload again. A mistake is shown in red in the Output, with its file and line, and the line is marked in the editor.
  6. To stop the sketch, unplug the USB (click the USB jack) or hold the reset button, as on a real Uno.

Build and Upload

  • Build (the check mark) compiles the sketch and its files with avr-gcc, as the Arduino IDE's Verify does, and reports what the program uses, in the Arduino IDE's words: Done: 2486 bytes of flash (of 32,256) and Global variables use 197 bytes (10%) of dynamic memory, leaving 1851 bytes for local variables. Maximum is 2048 bytes.
  • Upload (the right arrow) builds the sketch, loads the program onto the Uno, and starts it, as in the Arduino IDE. The USB cable must be plugged in.
  • Like the Arduino IDE, the simulator prepares the sketch before it compiles it: it adds #include <Arduino.h> when the sketch lacks it, and it declares each function that is used above the place it is written, so functions may come in any order. Templates and functions with default values are left as written: put those above their first use.
  • Each .cpp file of the sketch is compiled on its own and linked with the sketch, as in the Arduino IDE; its .h file declares what the sketch may use.
  • The program must fit the ATmega328P: 32,256 bytes of flash (the rest holds the boot loader) and 2,048 bytes of RAM. A sketch that does not fit is refused, as the Arduino IDE refuses it. Over 1,536 bytes of RAM (75%) gives the IDE's warning, because the local variables and the stack need the rest.
  • The program size here is larger than in the Arduino IDE (Blink is about 2,400 bytes here, about 900 there): the IDE also runs link time optimization, which removes unused parts such as Serial's buffers. The program runs the same way.
  • An unchanged sketch is not compiled again. A second click while a build runs waits for that build.
  • Each press starts a new Output; its first line names the button and the sketch, for example Upload: Blink.ino. The green Run LED beside Upload is on while the sketch runs.
  • The sketch runs until you press Build, upload another sketch, unplug the USB, or hold the reset button. The editor tab shows "changed since Upload" when the code differs from the sketch on the Uno.

Editor, Output, Serial Monitor, and Plotter

  • The editor is a real code editor (CodeMirror 6), in the Arduino IDE 2 colors on a white page: line numbers, auto indent, bracket matching and closing, folding (the ⌄ marks beside the line numbers), and completion of C++ and Arduino names and of the sketch's own words as you type.
  • Keys (Cmd in place of Ctrl on a Mac): Ctrl+Z and Ctrl+Shift+Z undo and redo; Tab and Shift+Tab indent the selected lines; Ctrl+/ makes the lines comments or code again; Ctrl+F finds and Ctrl+H replaces; Ctrl+G goes to a line; Ctrl+Space lists completions.
  • Several cursors: Alt+click adds a cursor, as in the Arduino IDE 2 and VS Code. Shift+Alt and drag selects a column.
  • Errors: each of gcc's messages marks its line in the editor (a red line); the editor goes to the first error, and opens the file it is in.
  • The bar above the editor has two rows: Build, Upload, Examples, Wire it for me, Help, and Reference, with the Uno's state at the right; then the files: New, Open, Save, Export, Open folder, and Reset Page.
  • Output shows Build and Upload messages and errors. Serial Monitor shows what the sketches print with Serial.print and Serial.println (the Serial Monitor shows output only; it does not send what you type).
  • The Serial Plotter graphs the numbers the sketch prints, one trace per number on a line. Print name:value pairs to name the traces, as in the Arduino IDE 2. Hide Plotter gives its room to Output and the Serial Monitor.

Examples, Files, and Reference

  • Examples: 45 sketches in sub menus, as in the Arduino IDE: Basics, Digital, Analog, Carpenter Software (the Numerics lessons, the finite state machines, and Robotics with JoystickDrive, JoystickDriveC, Programmer, and ChipJoystickDrive), and Protocols (SerialToChip, SerialCallResponse, MasterWriter, MasterReader, and SPIMaster, each with a sketch for the Uno and one for the chip). JoystickDrive runs the MageMCU Code-JUL files as written: its main sketch and the header ace.h.
  • Sketch files: the second row of tabs above the editor lists the sketch's files: the .ino first, then its .h and .cpp files. Press + to add one (a header gets include guards); ▾ on a file tab renames or deletes it. In the sketch, #include "ace.h" reads one of these files. All files of a sketch are in one folder, as in the Arduino IDE, so #include "claude/ace.h" finds ace.h too. A .cpp file is compiled on its own and linked with the sketch.
  • Libraries: <Wire.h> (I2C), <SPI.h>, and <Servo.h> are included, with avr-libc (for example <avr/eeprom.h>, <avr/pgmspace.h>, and <util/delay.h>). Any other library name is GCC's error that names it.
  • #include <Arduino.h>: every example starts with this line, so it copies straight into the Arduino IDE or a PlatformIO main.cpp (where the line is required); a sketch without it builds here, as in the Arduino IDE.
  • New starts an empty sketch. Save downloads one .ino file; its header files, circuit, power supply, lab modules, and Chip tab ride along as comment lines. Open loads such a file.
  • Export downloads the sketch as a folder in a .zip (Name/Name.ino with its .h and .cpp files) for the Arduino IDE. Open folder reads a sketch folder you choose: its .ino and its .h and .cpp files; other files are left out.
  • A file from an older simulator still opens: parts the long breadboard has no hole for are skipped, and the Output says how many.
  • Reset Page clears what this browser keeps and starts over.
  • Keep your work with Save or Export. The page also remembers your sketch and circuit in this browser, but only in this browser on this computer: clearing the site's data, another computer, or Reset Page loses it. Open and Open folder ask before they replace a sketch you changed.
  • Reference opens the AVR101 Reference: the Arduino C and C++ the examples use, and the limits.

Errors and What They Mean

Every error is gcc's or the linker's own message, in red in the Output, with the file and line where gcc found it. The most common ones:

The Output saysIt means
sketch.ino line 7: expected ';' before '}' tokenA missing semicolon: look at the line above line 7.
'ledPin' was not declared in this scopeA name used before it is declared, or misspelled (C++ tells capital and small letters apart: digitalwrite is not digitalWrite).
LiquidCrystal.h: No such file or directoryA library this simulator does not have (it has Wire, SPI, and Servo), or a file name that is not one of the sketch's tabs.
undefined reference to setup (every sketch needs setup() and loop())The sketch lacks setup() or loop(), or a function is declared but never written.
multiple definition of countThe same variable or function is defined in two files, or a header without include guards is included twice.
not enough memory. Global variables use 3197 bytesThe global variables need more than the ATmega328P's 2,048 bytes of RAM: make arrays smaller, or keep constant tables in flash with PROGMEM.
the compiler ran out of roomA template or a macro that never ends.

The Uno

  • The Uno lies beside the instruments, its USB jack and power jack at the right. Its digital pins (0 to 13) run along its bottom edge, over the breadboard; its power and analog pins along its top edge, and their wires run around the Uno to the board.
  • Rest the cursor on a pin to see a hint with its name and job, for example "D13 (pin 13): SCK, LED L" or "A4 (analog in, D18): SDA (I2C)".
  • Click the USB jack to plug or unplug the Uno. The ON LED shows power.
  • The Uno has a 500 mA USB fuse (a polyfuse), as the real board does. A short from 5V or 3.3V to GND opens it: the Uno goes off and its state reads "USB fuse open (short)". Remove the short and the fuse closes again.
  • Hold the red reset button, or wire RESET to GND, to hold the Uno in reset.
  • The L LED is on pin 13; TX blinks when the sketch prints.

The Bench Layout

  • Top: the AVR101 title bar across the bench.
  • Under it, left: the power supply (Bus A to D), and under that the BENCH: the scope above the multimeter, and beside them the Uno. Right: the Electronics Lab, a square of four slots.
  • Bottom: one long breadboard of 68 columns across the whole bench. Its left half (columns 1 to 34) has Bus A on the top rails and Bus B on the bottom rails; its right half (columns 35 to 68) has Bus C on the top and Bus D on the bottom. The bus letters sit at the outer ends.
  • The examples follow four wiring rules: the circuit starts under the Uno pins it uses; a module's circuit sits under its dots; the Uno GND (the GND pin beside 5V) joins the − rails of all four buses; and the ATmega328P goes on the breadboard between the Uno and the Electronics Lab.

The Breadboard and Components

  • Rows a to e and f to j: the five holes in a column on each half are connected. The gap in the middle separates the halves.
  • Each half of the board has a top and a bottom pair of rails, each a + rail and a − rail: Bus A and Bus B on the left half, Bus C and Bus D on the right. The rail holes come in blocks of five, and the rails split in the middle, so Bus A and Bus C (and Bus B and Bus D) are separate until you wire them together.
  • Choose a component, then click two holes: a resistor 2 to 8 holes apart; an LED with the long leg (+) first; a wire from a pin or hole to another pin or hole. After each part the tool turns off, so the next click works the circuit; choose the tool again for another part. Escape also turns a tool off.
  • Resistors: 220 Ω to 1 MΩ, including 4.7 kΩ (the usual I2C pull up) and 1 MΩ.
  • Capacitor (22 pF, 0.1 µF, or 22 µF) and Crystal 16 MHz: placed like a resistor. With steady voltages a capacitor and a crystal pass no current, so they change nothing in the circuit yet; they are saved with it, ready for the ATmega328P on the breadboard, which needs the crystal and two 22 pF capacitors to run. For the 22 µF (electrolytic), place the + leg first.
  • Hold a button to press it. Drag a knob or a light sensor to change it.
  • Delete removes a part; Starter Circuit places two LEDs and a button; Clear Board removes every part.

Electronics Lab and Modules

  • The Electronics Lab at the right has four slots: slot 2 for modules to come, the Robot, the Thumb Joystick, and the L298N Driver, each module with an ON and OFF switch. Turning a slot OFF takes the module and its wires out; Clear Lab takes them all out. The breadboard stays.
  • The joystick and the L298N have connection dots in a row along the bottom of the lab, labeled above each dot: the joystick's under it (wired down to columns 51 to 55), and the L298N's in two groups, POWER (12V, GND, 5V, toward columns 60 to 62) and LOGIC (ENA, IN1 to IN4, ENB, toward columns 63 to 68). Wire them like the Uno's pins, to a pin or to a hole.
  • The motor connections: Motor A (OUT1, OUT2) above the L298N's upper left corner and Motor B (OUT3, OUT4) above its upper right corner; each robot motor's two leads in a lower corner of the robot's slot, LEFT and RIGHT (red +, black −). Wire each motor to one output pair with the Wire tool.
  • Thumb Joystick: two 10 kΩ potentiometers between +5V and GND (VRx and VRy) and a switch (SW) to GND. Drag the yellow knob; it springs back to the center when you let go (the arrow keys move it too). Hold SW to press the stick. The readout under it shows the VRx and VRy voltages.
  • L298N Driver, drawn as on the bench (Article 1003): the heat sink at the top, the power terminal at the lower left, the logic header at the lower right. ENA gates OUT1 and OUT2 (IN1 drives OUT1, IN2 drives OUT2); ENB gates OUT3 and OUT4 (IN3, IN4). An IN pin HIGH switches its output to the 12V dot's voltage less about 2 V (lost inside the L298N); LOW switches it to GND. Both outputs at one level brake the motor; the enable LOW lets it coast. PWM (analogWrite) on ENA or ENB sets the speed. Its 5V dot needs 5 V (the 5V jumper is off, as in Joystick-Uno-L298N), and its GND must be joined to the Uno GND; the lab says which is missing.
  • Robot: two wheels 12 cm apart, each turned by a 24 Ω motor. Each wheel follows the volts across its own motor's leads (+ above − turns it forward), so the wires decide which output drives which wheel, and which way. It stays in its slot, pointing up, and shows what it would do: an arrow at each wheel (up for forward, down for back, longer with more volts) and a curved arrow for the turn, with a note under it (stopped, straight ahead, turning, or pivot). The left and right motor volts show under it; a motor not wired, with a loose lead, or split over A and B is named instead.
  • Try Examples, Carpenter Software, Robotics, JoystickDrive: the drive program of Joystick-Uno-L298N (MageMCU), Code-JUL's main sketch and ace.h unchanged, with the motors on Bus D at 14 V. Press Upload, hold SW once (the LED on D12 lights), then drag the joystick. JoystickDriveC is the same program in plain C, for comparison.
  • Never wire 8 V or more to the Uno 5V pin, a 5V dot, or an Uno pin: those voltages are for the L298N's 12V dot only.

Wiring the Robot: Step2_JUL and the MMC

This is one big puzzle, and Article 1009, the Parent, Teacher, and Student Guide, is its guide: the L298N Setup, Circuit-1, and the Motor Movement Checklist, with the printable forms in 1009 Supplemental. Both are on the Robotics page, with the articles 1009 builds on: 1000 Introduction Robotics, 1001 Joystick Algorithm, 1002 Arduino Uno, 1003 L298N Motor Driver, and 1004 Experiments.

The bench running Step2_JUL on the Uno: the joystick and the L298N wired under their dots, the motor wires from the L298N's outputs to the robot
Step2_JUL on the Uno (Wire it for me ON) at bits_0000: Circuit-1, the joystick pushed forward, and the robot pivots (left 11.95 V, right −11.95 V), so bits_0000 fails at Forward: on to the next row of the Motor Movement Checklist. "MMC: one value fits" on the lab's title line.
The bench running ChipJoystickDrive: the Uno with its chip pulled as the programmer, the ATmega328P on the breadboard between the Uno and the lab driving the L298N and the robot
ChipJoystickDrive: the Uno as the programmer (its chip pulled), the ATmega328P on the breadboard between the Uno and the lab driving the L298N and the robot, with what the chip needs beside it: the 16 MHz crystal across pins 9 and 10, a 22 pF capacitor from each of those pins to GND, 0.1 µF across VCC and GND, and the 10 kΩ pull up on RESET.
  • Choose Examples, Carpenter Software, Robotics, Step2_JUL: the L298N Setup of Article 1009, simplified for the simulator (the same octant algorithm, joystick correction, dead zone, latching button, and Bits() rules as the program in Joystick-Uno-L298N). It starts at bits_0000.
  • Wire it for me ON: the example wires Circuit-1 for you, the motors included (Motor A to the right motor, Motor B to the left). OFF (the advanced way): the example places the modules and turns on Bus D, and you add every wire: the L298N's POWER and LOGIC, the joystick, and the motors.
  • Press Upload, press SW once (the LED on D12 lights: the motors may run), then run the Motor Movement Checklist (MMC): 16 rows (bits_0000 to bits_1111) by 8 joystick positions (Right Turn, North-East, Forward, North-West, Left Turn, South-West, Backward, South-East), 128 cells in all. Push the joystick to each position in turn and watch the robot's arrows. At the first wrong movement, stop: change the Bits() line to the next value, Upload, and start the next row. The first value that passes all 8 positions is the value of your bench. Change the value, never the wires.
  • The note over the L298N checks your wiring as you build it, with the same model as Motor-Movement-Checklist/BitsProof.py of the repository: MMC: one value fits (green) means one of the 16 values will drive your bench correctly; it never says which. MMC: no value fits (red) names the rule your wiring breaks.
The connection rules (Motor-Movement-Checklist, ReadMe)
RuleConnection
1D5 and D10, the two PWM pins, go to ENA and ENB, either way.
2D6 and D7 go together to one IN pair (IN1 and IN2, or IN3 and IN4), in either order; D8 and D9 go to the other IN pair.
3The two leads of each motor go to one output pair (OUT1 and OUT2, or OUT3 and OUT4); either motor may use either output, with either polarity.
4Power, the 5 V logic supply, and the common ground as in Circuit-1 (Article 1009). No value corrects a power or ground fault.
5The joystick: VRx and VRy on A0 and A1, either way; SW on D2.
Forbidden connections, and how the simulator tells you
KindExamplesWhat you see
Damaging12 V (an L298N output or Bus D) on an Uno pin or a 5V dot; the Uno 5V wired to GND; an LED with no resistorThe part or pin burns and is drawn burned, and the Output names it; a 5V short opens the USB fuse. Reset Breadboard replaces burned parts.
ShortsAn L298N output wired straight to its GND; a bus + rail wired to its own − railA Short circuit warning under the board names it.
Breaking a ruleD6 and D7 split over both IN pairs; D5 and D10 not on ENA and ENB; a motor split over A and B; A0 or A1 not on VRx or VRyMMC: no value fits over the L298N, with the rule.
MissingThe L298N's GND not joined to the Uno GND; no 5 V on its 5V dot; 12V with no return; a loose motor leadA red note in the L298N's or the robot's slot says what is missing.
  • With the ATmega328P: ChipJoystickDrive runs the drive program on the chip on the breadboard, with the Uno as its programmer (see ATmega328P on the Breadboard). The motor wires and the MMC check work the same way; the chip's pins 11 to 16 are D5 to D10, and its pins 23 and 24 are A0 and A1. The chip runs only with its crystal and capacitors: the 16 MHz crystal across pins 9 and 10, a 22 pF capacitor from each to GND, 0.1 µF across VCC and GND, VCC and AVCC on 5 V, both GND pins on GND, and RESET pulled up (10 kΩ); the Output names whichever is missing.

ATmega328P on the Breadboard

  • Choose ATmega328P in the Components column, then tap the column for pin 1 (any row): the chip goes across the middle gap, pins 1 to 14 along row f and pins 15 to 28 back along row e, as a real chip sits on a breadboard. It is drawn as the 0.300 inch package: its body nearly reaches its pins.
  • Wiring Rule 4: the examples place it between the Uno and the Electronics Lab, pin 1 at f36 (columns 36 to 49). That half's bottom rail is Bus D, the motor supply, so VCC and GND (pins 7 and 8) reach Bus B by wires around the chip's left end, and AVCC and GND (pins 20 and 22) go to Bus C. No wire runs over the chip.
  • It runs only when wired as the real chip needs: 5 V on VCC (pin 7) and AVCC (pin 20), GND (pins 8 and 22) joined to the Uno GND, a 16 MHz crystal across pins 9 and 10 with a 22 pF capacitor from each to GND, and RESET (pin 1) HIGH. Its own pull up holds RESET HIGH; add 10 kΩ as on a real board. A 0.1 µF capacitor across VCC and GND is advised. The Output says what is missing.
  • Above 6 V on VCC or AVCC the chip burns; Reset Breadboard replaces burned parts.
  • Its Arduino pins are the real chip's: D0 pin 2, D1 pin 3, D2 to D4 pins 4 to 6, D5 to D7 pins 11 to 13, D8 to D13 pins 14 to 19, A0 to A5 pins 23 to 28.
  • The Uno as a programmer: click the Uno's chip to pull it from its socket (click the empty socket to put it back). Wire Uno pin 0 (RX) to chip pin 2 (RXD), Uno pin 1 (TX) to chip pin 3 (TXD), and the Uno RESET to chip pin 1. The same names go together, because the Uno's USB chip already crosses its lines.
  • Uno and Chip tabs: each tab has its own sketch. Upload sends the open tab to its chip; the Chip tab uploads through the Uno with its chip pulled, and Output lists anything missing. The chip's Serial reaches the Serial Monitor through the Uno. The breadboard chip keeps its sketch when the Uno's chip goes back in.
  • On a real Uno an upload can fail while something drives pin 0; the Output gives a note when pin 0 is wired.
  • Examples, Carpenter Software, Robotics: Programmer (Blink and Serial on the breadboard chip) and ChipJoystickDrive (the drive program on the breadboard chip).

Serial, I2C, and SPI between the Chips

  • The Uno and the ATmega328P on the breadboard each run their own sketch (the Uno and Chip tabs) on their own simulated chip. They talk only through the wires on the breadboard, as two real chips do: a pulled wire stops the talk.
  • Examples, Protocols: each example loads both sketches and wires both chips (Wiring Rule 4). The Uno's chip comes pulled: open the Chip tab and press Upload (the Uno uploads it to the breadboard chip); then click the empty socket to put the Uno's chip back, open the Uno tab, and press Upload. The comment at the top of each sketch gives these steps.
  • Serial (SerialToChip, SerialCallResponse): the Uno's TX (pin 1) to the chip's RX (pin 2), and the chip's TX (pin 3) to the Uno's RX (pin 0): the lines cross. Both sketches must use the same baud rate in Serial.begin().
  • I2C (MasterWriter, MasterReader, with Wire.h): SDA (Uno A4) to chip pin 27, SCL (Uno A5) to chip pin 28, each with a 4.7 kΩ pull up resistor to 5 V, as the bus needs.
  • SPI (SPIMaster, with SPI.h): the Uno's pins 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK) to the chip's pins 16, 17, 18, and 19.
  • See it on the scope: with the multimeter on V, put the red probe on a protocol wire (TX, SDA, SCL, MOSI, MISO, SCK, or SS) and the black probe on GND. The scope draws the last byte bit by bit and names it, for example UART 9600 0x41 'A', I2C SDA 0x08 ACK, or SPI MOSI: MOSI 0x01 MISO 0x64.
  • Break it: pull a wire while the sketches run and watch the result change (for example, an I2C write returns 2, no answer, without SDA), then put it back.

Power Supply

  • The power supply runs across the top of the bench with four buses, A (teal), B (orange), C (purple), and D (green). Each has a display, + and − (0.1 V a click; hold for 1 V steps), SET with presets (OFF, 3.3, 5, 9, 12, 15 V), and an ON and OFF switch that keeps its voltage. The range is 0 to 18 V; 8 V and up are for the L298N motor supply.
  • Bus A feeds the top rails of the left half, Bus B the bottom rails of the left half, Bus C the top rails of the right half, and Bus D the bottom rails of the right half.
  • Each bus is an isolated output, independent of the other buses: its − rail joins nothing until you wire it. A wire from a bus + rail straight to its own − rail is a short, and the supply warns.
  • The supply GND is separate from the Uno GND. Wire the bus − rail to an Uno GND pin so the sketch and the supply share a common ground (the examples do this for all four buses).
  • Measure a bus with the multimeter: the red probe on a + rail hole, the black probe on a − rail hole.

Multimeter

  • V: click the red probe, then a hole or pin; then the black probe and another hole or pin. It reads the voltage from red to black (a PWM pin reads its average). The meter has a 10 MΩ input, as a real meter. When the two probes are on parts of the board with no circuit between them (a bus whose − rail is not wired, for example), it reads 0.00 V and shows OPEN. The oscilloscope does the same.
  • mA: the meter goes in series, as on a real meter. Open the circuit where you want to measure: delete a wire (or move a lead). Put the red probe on one end of the gap and the black probe on the other. The meter closes the gap and reads the current from red to black. Example: in Blink, delete the wire from pin 13 and put the red probe on pin 13 and the black probe on the hole where the wire ended; the LED lights and the meter reads about 12 mA.
  • Never put the mA probes across a source (for example 5V and GND, or a pin and GND): that is a short circuit. Over 200 mA the meter's fuse blows and it shows FUSE; press UNPLUG to replace the fuse. A pin can burn before the fuse blows. Press UNPLUG before you change to mA.
  • Ω: put the red and black probes on two holes or pins of a circuit with no power. The meter reads the resistance between them through resistors, wires, pressed buttons, the knob, and the light sensor. Two holes in the same strip read 0.0 Ω; with nothing between them it reads OL; an LED reads OL. A part on its own, such as a resistor with nothing else wired to it, reads while the Uno runs. When either probe's circuit is powered (by the running Uno or a bus that is ON) the meter shows PWR ON, as a real meter warns: unplug the USB or turn that bus off first.
  • UNPLUG takes both test leads off the board.

Oscilloscope

  • The scope sits above the multimeter, under the power supply, and uses the same red and black probes. It shows the voltage from red to black over time; with only the red probe placed it measures to GND. Keep the multimeter on V.
  • PWM (analogWrite) and tone() show their square wave: 490 Hz on pins 3, 9, 10, and 11, 980 Hz on pins 5 and 6, or the tone frequency. A rising edge starts each sweep one division from the left, so the wave stands still. Try Fade with the red probe on pin 9 and watch the pulse width change.
  • Slower signals, such as Blink, scroll across the screen. Try Blink with the red probe on pin 13 and 500 ms per division.
  • ◀ ▶ set the time per division (1 µs to 500 ms); the next button sets 1, 2, or 5 volts per division (5 V for the 8 to 18 V buses); RUN or HOLD freezes the screen. The readout shows the frequency, duty cycle, and peak voltage. Ground (0 V) is one division above the bottom.
  • When a wave is too fast for the time per division, it shows as a band between its low and high levels; choose a shorter time per division to see each pulse.

Mistakes and Burned Parts

  • Mistakes burn parts, marked with a red X: an LED over 50 mA, a resistor over 0.3 W, an Uno pin over 80 mA or above 5.5 V, and the Uno itself above 5.6 V on its 5V pin.
  • The page warns above 20 mA per LED or pin. Try 24.MistakeLab in the Examples.
  • Reset Breadboard replaces burned parts and keeps the wiring.

Computer Requirements

  • A desktop or laptop computer with a mouse or trackpad. Phones and tablets are not supported.
  • A window at least 1100 pixels wide. Up to 2099 pixels, the editor sits under the bench (the bench at its full width); from 2100 pixels (a large monitor), the bench and the editor sit side by side.
  • A current version of Chrome, Edge, Firefox, or Safari, with JavaScript and WebAssembly on.
  • The page loads about 1.2 MB once; the first build of a visit loads the compiler (about 13 MB, kept by the browser). While a sketch runs it uses a small part of one processor core; a computer from the last ten years runs it smoothly.
  • Nothing is installed, and no account is needed. Sound (tone) needs speakers or headphones.

Speed and Timing Limits

The simulator runs the compiled program on a simulated ATmega328P at 16 MHz, instruction by instruction, in your browser:

  • Clock: the chip's own timers keep millis(), micros(), and delay(), as on a real Uno. The simulation runs in slices to keep up with real time; on a slow computer it may fall behind, and the sketch then runs slower than real time (its own timing stays right).
  • Screen: LEDs, meters, the joystick, and the robot update about 60 times a second (every 16.7 ms). A pulse shorter than that shows on the scope, not as an LED blink.
  • PWM and tone(): from the chip's timers, so the scope shows them at their true speed (490 Hz, 980 Hz, or the tone).
  • Two chips (the Uno and the ATmega328P on the breadboard): each runs on its own simulated chip, side by side; Serial, I2C, and SPI pass between them only through the wires.

Privacy and Limits

  • Your sketches (Uno and Chip tabs) and their header files, the circuit on the breadboard, power supply settings, the modules in the Electronics Lab, and whether the Uno's chip is pulled are kept in this browser only. Nothing is sent to a server.
  • Export makes its .zip in this browser. Open folder reads only the folder you choose, only in this browser, and only its .ino, .h, and .cpp files at the top level; nothing is uploaded.
  • Security: an opened file is read as plain text and is never run as page code. Each part in a file's circuit is checked (known part, real holes, known values), and so is the list of lab modules (known modules only), each header file (a plain name ending in .h or .cpp, at most 100 KB, at most 15 files), and the Chip tab is checked (a plain name, text code, and yes or no for the pulled chip) and kept as text until you press Upload; anything else is skipped. Your sketch and its files are compiled by GCC in your own browser (in a Web Worker) and never sent anywhere; the compiled program runs only inside the simulated ATmega328P. A sketch over 2 MB is refused, a build over 60 seconds is stopped, and a program larger than the Uno's flash (32,256 bytes) or RAM (2,048 bytes) is refused. #include reads only the sketch's own files and the compiler's Arduino headers, never a path or a web address. The page loads code only from this site and Google Analytics. The compiler's source is offered on its source page.
  • The simulator is experimental and under development. A bug is an error in a program; if a result looks wrong, check it against a real circuit. The Enigmatic Bug stamp marks the site's experimental pages.
  • Not covered: libraries other than Wire, SPI, and Servo, and typing into the Serial Monitor; on a slow computer the chip may fall behind real time. See the Limits list.
  • Designed: Jesse Carpenter and Claude (Anthropic). Simulator code: MIT License.