Blink — your first firmware

The smallest complete hal project: create it, toggle the onboard LED, and test it on real hardware — the whole flow end to end.

Click through the files — it's the whole project

Blink — your first firmware — Visual Studio Code
Select a file from the explorer
xiao_ble/nrf52840 GPIO · Time · testing

The whole flow

1 — Create the project

terminal
npx @typecad/hal create my-project --target xiao_ble/nrf52840
cd my-project

2 — Write the program

Open src/main.ts and replace the starter with the blink program from the editor above. That's the entire program — construction carries the configuration, and the while (true) loop is the main loop.

3 — Compile and flash

terminal
npx @typecad/hal build --compile --upload --port COM4

When the flash finishes, the onboard LED blinks twice a second. Change 500 to 100 and rebuild — the whole edit-build-flash cycle is one command.

4 — Test it on the real board

test/blink.test.ts runs on the board itself: the tests are flashed, their assertions evaluate on real hardware, and pass/fail comes back over serial.

terminal
npx @typecad/hal test

  Blink
    ✓ turns the LED on
    ✓ turns the LED off

  2 passing

Where to go next

© 2026 typeCAD — code-defined electronics github