Skip to content
Beta: this feature is still in development and may change.

Microcontrollers

A microcontroller in CRUMB runs real firmware. Write an Arduino sketch, compile it, and the chip runs the same machine code it would on your desk, driving its pins into the circuit around it, cycle by cycle. A loose wire, a missing pull-up or a brown-out does what it would do for real.

CRUMB runs these chips, and compiles sketches for the boards built on them:

Family Chip Compiles for
AVR ATmega328 Arduino Nano, Uno, Pro Mini and Mini
AVR ATmega2560 Arduino Mega 2560 and Mega ADK
ARM RP2040, dual core Raspberry Pi Pico, and Pico W without its radio
Xtensa ESP32, dual core ESP32 DevKit V1 and ESP32 Dev Module
RISC-V ESP32-C3 ESP32-C3 Dev Module and SuperMini

The Arduino Nano is built into CRUMB, in the Microcontrollers category of the toolbox. A board built on any of these chips can be made in the component editor: Add MCU Module on its PROGRAMMING tab adds the chip. A board needs real power on its supply pins, just like the real thing.

Select the board and look at the Firmware section of the inspector.

  1. Press New sketch. It starts as a blink, in a file called main.ino.
  2. Press Edit, or double-click the file, to open it in the Script Editor.
  3. Write your code. The editor completes Arduino functions as you type, shows their parameters, and underlines errors.
  4. Save. CRUMB compiles the sketch and loads it into the board straight away, even while the simulation runs.

To split a sketch into files, type a name such as motor.cpp in the new-file box and press Add. main.ino is the sketch’s starting point, so it can’t be deleted.

The sketch is saved inside your circuit, along with the board’s libraries, its EEPROM and its clock, so a shared circuit carries its code with it. Passwords and keys are the exception: keep them in private headers.

Compile builds the sketch without opening the editor. While it builds, CRUMB says so. The first build for an ESP32 takes a minute or more; later builds are much quicker.

If the code doesn’t compile, a Compile Failed dialog says how many errors there are, and the errors themselves are listed in the editor’s console, where you can click one to go to it. The board stops until the sketch compiles, rather than carrying on with old code that no longer matches what you wrote.

Each board has its own Libraries (per-Arduino) list. Press Add .zip and pick an Arduino library’s zip file to add it to that board. Its examples and documentation are left out. The standard libraries that come with each core, such as Wire, SPI, EEPROM and SoftwareSerial on the AVR boards, are there already.

If your sketch includes a library the board doesn’t have, the compiler says it can’t find the header. Add the library’s zip and compile again.

A sketch that connects to Wi-Fi or a web service needs a password or a key, and those shouldn’t travel with a circuit you share. Keep them in a private header instead.

  1. In the board’s Firmware section, find Private headers and press Open folder.
  2. Put a header file there, such as secrets.h, with your values in it.
  3. In your sketch, #include "secrets.h" as usual.

The header is compiled into the board’s firmware on your computer only. The circuit never saves it: when you save, CRUMB keeps the sketch instead of the compiled firmware, and rebuilds the board when the circuit opens, using that computer’s own private headers. While it does, the board shows Rebuilding on this machine…; if it can’t, it says the board isn’t running and why.

CRUMB also checks that a private value hasn’t been copied somewhere else in the circuit, such as a part’s setting. If it finds one, it leaves it out of the save and lists it in the Output Log. A value in a header that isn’t really secret, such as a host name, can be marked with the comment // crumb:public on its line.

Flash board builds the real board with your private values included, and Export .hex asks before exporting firmware that contains them. A part can’t be saved to your library, or published to the Workshop, while it holds a private value.

To run firmware built somewhere else, press Load firmware and choose a file:

Chip File
AVR .hex
RP2040 .uf2 or .bin
ESP32 and ESP32-C3 .bin, as a full flash image

The Firmware section then shows the loaded bytes instead of a sketch. Clear — use sketch goes back to the sketch. Export .hex saves the board’s current firmware as an Intel HEX file.

ESP32 wireless only works with firmware compiled in CRUMB.

The board’s status shows at the top of its Firmware section:

Status Means
Running The firmware is running.
In reset The reset pin is held low.
Crashed The firmware faulted. Press Reset to reboot.
In bootloader A boot-mode pin was held at reset, so the firmware never started. Reset with it released.
Unpowered The board has no power, or not enough.

Reset reboots the board as if it had been switched off and on. Pulling its reset pin low holds it in reset, as on the real board. Reset State on the ribbon powers every chip up fresh but keeps what’s in EEPROM and flash.

The Clock menu sets the chip’s speed. A lower clock makes the simulation faster, because there’s less to simulate, but makes the firmware slower. Speeds above the chip’s rating are marked (turbo).

The board runs in simulated time, in step with the rest of the circuit. The rate readout on the SIMULATION tab shows whether the whole circuit is keeping up with real time.

Open it from Add Tool Panel ▼, then pick the board in its menu. You can open several, one per board.

  • The baud rate is whatever your sketch set with Serial.begin, shown in the toolbar.
  • Type in the send to the board… box and press Enter or Send. Choose the line ending your sketch expects: Newline, Both NL & CR or No line ending.
  • ↓ Auto keeps the newest output in view.

The monitor shows a board’s main serial port: Serial on an AVR board, the USB serial port on a Pico, UART0 on an ESP32, and on an ESP32-C3 either UART0 or, for the USB CDC on boot and SuperMini targets, its USB serial port.

A board talks to the rest of the circuit through its pins, the same way it would on a breadboard.

  • Digital pins drive and read real voltages. PWM pins put out a real square wave you can see on the scope.
  • Analog inputs read the voltage on the pin: A0 to A7 on an ATmega328 board such as the Nano, A0 to A15 on the Mega, and GP26 to GP28 on the Pico.
  • UART, I²C and SPI reach any part that speaks them, as long as it’s actually wired to the right pins. Remember to cross TX and RX.

Displays, sensors and LED strips in the library, such as the SSD1306 and ST7735 screens, the DHT22 and DS18B20 sensors and WS2812 LEDs, work with their usual Arduino libraries.

Two boards can talk to each other over UART, and one can be an SPI peripheral of the other. A board acting as an I²C peripheral can receive writes, but can’t answer reads yet.

ESP32 and ESP32-C3 boards have a radio, and every board in the circuit shares the same air.

  • Wi-Fi: an access point called CrumbNet, password breadboard, is always there to join. It hands out addresses, answers pings, and runs a small test web server: a GET for /hello returns crumb-hello. Boards on it can also talk to each other.
  • ESP-NOW: boards can send packets straight to each other.
  • Bluetooth LE: boards see each other’s advertising when they scan, along with a built-in test beacon called CrumbBeacon.

An ESP32 or ESP32-C3 board can also reach real servers on the internet, through your computer: web servers, APIs, time servers. Select the board and turn on Real internet in the Internet section of the inspector. CRUMB asks first, naming the board.

  • It’s outbound only: the board’s program can connect out, but nothing on the internet can connect in to it.
  • Private and local addresses are always refused: your router, the other devices on your network, and your computer itself.
  • The board’s Wi-Fi joins whatever network name its program asks for, so a sketch written for your home network runs unchanged.
  • It’s for that board, for this session only. It’s never saved with the circuit and is off again whenever the circuit is opened, and a copy of the board starts with it off.
  • Switch it off at any time to cut every connection at once.

While it’s on, the Internet section shows the board’s open connections, the data sent and received, any refused connections and the latest connection log. Real servers keep real time, so if the simulation runs slower than real time with connections open, CRUMB warns you that a server may time the board out.

Real internet isn’t available during a learning challenge.

When your sketch works in CRUMB, you can put it on the real board. Plug the board in over USB, choose its Port in the Firmware section (press ↻ if it isn’t listed), and press Flash board. CRUMB compiles the sketch again for the board’s real clock speed before it uploads, so the real board runs at the right speed even if you sped up the simulation.