Arduino Uno simulator

About

About this simulator

Build circuits on a breadboard, write a sketch and run it on a simulated Arduino Uno. Every reading is calculated from the real parts.

How it works

The bench has an Arduino Uno and a full-size breadboard. Pick a job from one of the four levels, or choose Free build to make anything you like with every part.

  • Add parts. Press Add a part to open the parts box: over 240 parts, searchable and sorted into resistors, capacitors, LEDs and displays, sensors, chips, transistors, motors and more. Tap the hole for each leg. Chips and buttons straddle the centre gap.
  • Wire it. Choose Wire, then tap one hole or Arduino pin and then the other. Wires to GND are black and wires to 5 V are red, as on a tidy bench.
  • Write the code. The editor takes normal Arduino C++: setup() and loop(), variables, arrays (including 2-D arrays), structs, functions, if, for, while, switch, Serial, analogRead, analogWrite, tone, millis, pulseIn, shiftOut and the Servo library. Press ✓ to verify and → to upload, and errors show the line, like the Arduino IDE.
  • Keep it. Your board and code are saved in this browser for each job. Save to file downloads the circuit and sketch together, and Open file loads one back, on this or another computer.
  • Test it. Press buttons, turn knobs and move the light, temperature and distance sliders. Tap any part to see its live voltages and currents, or use the multimeter. Then press Check my build.

Each job gives up to three stars: one for working, one for doing it without overloading anything, and one for doing it without opening the hints. Each part you damage is a safety strike, shown by the Safety dots at the top. Three strikes stop the job.

How accurate is it?

The circuit is solved properly, the same way circuit simulators like SPICE do it (nodal analysis with real diode and transistor equations), every frame. The numbers come from the parts' datasheets and the ATmega328P datasheet:

  • An output pin has about 25 Ω of internal resistance and sags under load. The datasheet's absolute maximum is 40 mA per pin and 200 mA in total; going over it damages the pin, and 20 mA is the sensible working limit.
  • INPUT_PULLUP is a 35 kΩ resistor. A pin left floating reads at random, as it does on a real board.
  • int is 16 bits and long is 32, so overflow behaves exactly as it does on an Uno. float and double are both 32-bit.
  • PWM runs at 490 Hz on pins 3, 9, 10 and 11, and 976 Hz on 5 and 6. analogRead is 10-bit and takes 112 µs. Serial sends 10 bits per character, so printing at 9600 baud really does slow the sketch down.
  • Buttons bounce for about a millisecond, motors need flyback diodes, LEDs need resistors, and the USB polyfuse trips on a short.
  • Interrupts on pins 2 and 3 (attachInterrupt) catch real edges, including button bounce, and take about 3 µs to enter. Forgetting volatile gets a warning.
  • Pointers, references, char arrays and the String class work as on an Uno, including the C string functions (strcpy, sprintf, dtostrf and friends). Writing past the end of an array is flagged, and sprintf prints ? for %f, just as the Uno's library does.
  • I2C (Wire) runs at 100 kHz on A4 and A5 and talks to the 16×2 I2C LCD byte by byte, so a wrong address, swapped wires or a missing lcd.init() fail the way they do on a real board. SPI drives D11 and D13 in all four modes.

Things it doesn't do: timing is accurate to a few microseconds rather than to the clock cycle, and the Uno can't be an I2C slave. Structs work (data members, arrays of structs, pointers and references to them), but classes, member functions, enums, templates and dynamic memory (new, malloc) don't: if a sketch uses one, the error names it and gives the line.