DEV Community


Getting started with Arduino and TinyGo: MBP M1 edition

Stepan Vrany
Interested in Go, Kubernetes and AWS.
・1 min read

Hey, this is gonna be a very short post. Today I wanted to play a bit with my old Arduino Uno but it took me some time to identify stuff that is specific for M1 processors.

As the first thing, we need to install all the tooling. Since there's limited support for Apple Silicons - we're gonna use Rosetta 2. Hence all the brew commands need to be prepended with arch -x86_64.

arch -x86_64 brew tap tinygo-org/tools
arch -x86_64 brew install tinygo

arch -x86_64 brew tap osx-cross/avr
arch -x86_64 brew install avr-gcc
arch -x86_64 brew install avrdude
Enter fullscreen mode Exit fullscreen mode

Now we can create our first Go/Arduino project.

cd ~
mkdir app
cd app
touch main.go
Enter fullscreen mode Exit fullscreen mode

And we can create the first Go sketch.

package main

import (

func main() {
    led := machine.LED
    led.Configure(machine.PinConfig{Mode: machine.PinOutput})
    for {
        time.Sleep(time.Millisecond * 10000)
        time.Sleep(time.Millisecond * 10000)
Enter fullscreen mode Exit fullscreen mode

This sketch will be blinking with integrated LED (ouptut 13). It's time to flash it to the Arduino!

tinygo flash -target arduino -port /dev/cu.usbmodem13201
Enter fullscreen mode Exit fullscreen mode

Please note that device /dev/cu.usbmodem13201
might be a bit different in your case. You can
identify the right one by listing /dev/cu.*.

Discussion (0)