STANNUM
Open the simulator

Tutorials / Getting started

Your first circuit: blink an LED

From an empty canvas to a blinking LED — placing a part, drawing wires, writing the code, saving and running. Ten minutes, and you will have used every part of the lab once.

This walkthrough builds the smallest complete project there is: one LED, two wires and a sketch that turns it on and off. Every screenshot is the real lab, so what you see here is what you will see on your screen. Open the simulator in another tab and follow along.

01 Meet the lab

The lab has three areas. On the left, the files of your project and the code editor. On the right, the canvas where the circuit is drawn — the board is already there, because every project has one. Below the canvas, the output panel: the build log and the serial monitor. The buttons at the top run and stop the simulation and open the menus.

A new project: the editor on the left, the board on the canvas, the output panel below. Nothing else yet.

If you have something on the canvas already, choose Project → New project to start from a clean board.

02 Add an LED

Parts come from the catalog: the Component button in the canvas toolbar. Click it and the catalog opens; there is a search box at the top if the list is long.

The Component button opens the catalog.
The catalog. Click the LED.

When you click a part, it sticks to the cursor. Move over the canvas and click where you want it — to the right of the board, with some room around it for the wires. Esc cancels if you change your mind.

The part follows the cursor until you click.
The LED on the canvas. Blocks can be dragged by their title bar at any time.

03 Wire the LED to the board

Select the Wire tool in the canvas toolbar. With it, a click on a pin starts a wire and the next click on another pin finishes it.

The Wire tool.

Click pin D13 on the right side of the board. The pin lights up: the wire has started, and it follows the cursor.

First click: pin D13 of the board.
The wire follows the cursor until the second click.

Now click A on the LED — the anode, the leg that receives current. The wire is drawn, and both pins take the color of the wire: they are on the same electrical net now.

D13 wired to the anode of the LED.

04 Close the circuit with a ground symbol

Current needs a way back. In the lab, ground is a symbol: every GND symbol on the canvas is the same node, exactly like the ground symbol in a schematic. Open the catalog again (switch back to the Select tool first, or press Esc), pick GND and drop it under the LED.

Then, with the Wire tool, connect the LED's K (the cathode, the short leg) to the ground symbol.

From the cathode to the ground symbol.
The complete circuit. The GND net is drawn in dark gray on every project.

05 Write the code

Click in the editor and replace what is there with the sketch below. pinMode() makes GPIO 13 an output; loop() turns it on and off every half second and prints a line each time.

sketch.cpp
#include <Arduino.h>

const int LED = 13;

void setup() {
  Serial.begin(115200);
  pinMode(LED, OUTPUT);
}

void loop() {
  digitalWrite(LED, HIGH);
  Serial.println("LED on");
  delay(500);
  digitalWrite(LED, LOW);
  Serial.println("LED off");
  delay(500);
}
The sketch in the editor. The number on the left is the line, which the build log refers to when something is wrong.

Note that the code talks about GPIO 13 and the wire goes to D13: the label on the board is the GPIO number with a “D” in front. If the number in the code and the pin on the canvas do not match, the LED simply will not blink — the most common mistake of a first project.

06 Save the project

Project → Save project (or Ctrl+S). The first time, the lab asks for a name. Saving does two things at once: it keeps the project in this browser, so it shows up under Open project…, and it downloads a .zip — your code as .cpp files plus the circuit — the copy you can keep, e-mail or open on another computer.

Save project, in the Project menu.
The name of the project appears on the right of the top bar.

07 Build and run

Press Build and run. Your code is compiled for real — the same compiler a physical board would use — and then loaded into an emulated chip. The status on the right goes Building, then Starting, then Running. A first build takes a while; the next ones only rebuild what changed.

The main button.

Running: the LED on the canvas blinks in step with the firmware, and every Serial.println lands in the serial monitor below the canvas. This is your code executing, not an animation of what it should do.

The simulation running. Watch the LED and the serial monitor.

Change delay(500) to delay(100) and press Build and run again: the LED blinks five times faster. That loop — edit, run, watch — is the whole method.

What you just used

See also