Hello World: Blink.

Arduino / C: Blink the built-in LED slowly and then quickly, repeating both rates in loop().

C++ snippet.ino
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  Serial.println("Slow blink: 500 ms on, 500 ms off");
  digitalWrite(LED_BUILTIN, HIGH);
  delay(500);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);

  Serial.println("Fast blink: 100 ms on, 100 ms off");
  digitalWrite(LED_BUILTIN, HIGH);
  delay(100);
  digitalWrite(LED_BUILTIN, LOW);
  delay(100);
}

Expected output EXAMPLE

Slow blink: 500 ms on, 500 ms off
Fast blink: 100 ms on, 100 ms off
Slow blink: 500 ms on, 500 ms off

Details

Targets Arduino Uno R3 (ATmega328P, 16 MHz) with the Arduino AVR core. Open as a sketch in the Arduino IDE and select Arduino Uno. Serial output uses 9600 baud. Tested with simavr; electrical characteristics and physical wiring are outside this simulation. Connect the Uno R3 by USB, select Arduino Uno and its port, then upload. The built-in L LED is on D13; no external LED or resistor is needed. setup runs once; loop repeats. Change the delay values to change the rates. Open Serial Monitor at 9600 baud. The recorded output covers the first 1.3 seconds; the sketch continues blinking afterward.

✓ Verified

Tested on Ubuntu 24.04.5 LTS · · Uno R3 / ATmega328P at 16 MHz; simavr 1.6+dfsg-3build2 · simavr 1.6+dfsg-3build2; arduino-cli Version: 1.5.1 Commit: 01f3d4f2b Date: 2026-06-05T10:22:17Z; Arduino AVR core 1.8.6

Test inputs, results and environment

The exact published code ran in a dedicated Linux test container with prepared inputs. Snippet process uid 65534 with a read-only root filesystem and temporary working files. Networking disabled. The exact sketch was compiled for Uno R3 and simulated at 16 MHz. UART output is shown below; compiler logs and measured GPIO traces are retained in the test evidence. Fixtures and output records are isolated from the application database. Testing covers this example and its stated checks, not every input, operating system, or runtime version. The Linux container shares its host's kernel; this is not a native Windows test.

Architecture / host kernel
x86_64 / 6.18.54.1-microsoft-standard-WSL2
Snippet identity / locale
uid=65534, gid=65534 (unprivileged process) / C.UTF-8
Interpreter invocation
arduino-cli compile --fqbn arduino:avr:uno; uno-sim sketch.ino.elf (capture UART and D13 transitions)
Container image ID
sha256:ec91410a8f6ec3e985830b5e3a0560306d36f8c1c5ccd91a6699abe707123fa3
Code SHA-256
d27c498f8cdc1f3ecf6b90cbc74adc6827b44f846e3c197fe10cfb29d6026c19
Dependencies
simavr 1.6+dfsg-3build2; arduino-cli Version: 1.5.1 Commit: 01f3d4f2b Date: 2026-06-05T10:22:17Z; Arduino AVR core 1.8.6

Test input setup

These are the prepared inputs used by the test harness. See Details above for the prerequisites and how to run this example.

Simulator inputs: {"sim_ms": 1300, "serial_input": "", "pin_input": "none"}

Observed standard output

Slow blink: 500 ms on, 500 ms off
Fast blink: 100 ms on, 100 ms off
Slow blink: 500 ms on, 500 ms off

Exit code: 0. Standard error: empty. Validation: Exact stdout comparison. System-dependent values above are one recorded run.

Additional assertions that passed

Checks recorded by the test harness. Where Python assertions are shown, browser cases use Playwright and simulator cases may inspect pin transitions: result.stdout is captured output, work is the temporary directory, and Path is pathlib.Path. The harness also imports json and csv.

trace = [tuple(map(int, line.split(','))) for line in Path('pin13.csv').read_text().splitlines()]
pulses = [(trace[i+1][0] - cycle) / 16000 for i, (cycle, value) in enumerate(trace[:-1]) if value == 1 and trace[i+1][1] == 0]
assert len(pulses) == 2
assert 498 <= pulses[0] <= 502 and 98 <= pulses[1] <= 102
assert trace[-1][1] == 1
falls = [(trace[i+1][0] - cycle) / 16000 for i, (cycle, value) in enumerate(trace[:-1]) if value == 0 and trace[i+1][1] == 1 and cycle > 16000]
assert len(falls) == 2 and 498 <= falls[0] <= 502 and 98 <= falls[1] <= 102