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
Now we can create our first Go/Arduino project.
cd ~
mkdir app
cd app
touch main.go
And we can create the first Go sketch.
package main
import (
"machine"
"time"
)
func main() {
led := machine.LED
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
for {
led.High()
time.Sleep(time.Millisecond * 10000)
led.Low()
time.Sleep(time.Millisecond * 10000)
}
}
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
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.*
.
Top comments (0)