Blinky on Arduino UNO with Zig

Let’s give Zig a try on Arduino UNO with microzig

Lets create and setup our project first:

mkdir blink && cd blink
zig init-exe

Now we can add microzig as a dependency, for now lets do this in a simple manner, no package managers, just git:

mkdir deps
git clone deps/microzig

Lets now setup build.zig:

const std = @import("std");
const microzig = @import("deps/microzig/src/main.zig");

pub fn build(b: * !void {
    const backing = .{
        .board = microzig.boards.arduino_uno,

    var exe = microzig.addEmbeddedExecutable(


And now it’s time to write actual blink code:

const micro = @import("microzig");

const led_pin = micro.Pin("D13");

pub fn main() void {
    const led = micro.Gpio(led_pin, .{
        .mode = .output,
        .initial_state = .low,

    while (true) {

fn busyloop() void {
    const limit = 100_000;

    var i: u24 = 0;
    while (i < limit) : (i += 1) {

After that we should be able to build this:

zig build
ls zig-out/bin

And we can now use avrdude to upload this to our Arduino UNO.

avrdude -carduino -patmega328p -D -P /dev/ttyACM0 -Uflash:w:./zig-out/bin/blink:e

Double check what your device is on your OS, on apple silicon macbook for me device was /dev/cu.usbmodem11101.

Thats it, it should be blinkin!