Working with TinyGo on Arduino

Building microcontroller projects is a great way to level up your electronics and programming skills.

The purpose of this post is to share some setup instructions to get you up and running with your Arduino Uno and TinyGo as quickly as possible.

TinyGo

Here are some useful resources for getting started;

The avr-gcc compiler takes high-level code and creates a binary source that can be uploaded into an AVR microcontroller.

Getting Started

Components & Dev Environment

Installation & Setup

Configuring Goland IDE

Once you have imported the project we have a couple of settings to update to ensure the IDE recognizes the TinyGo libraries our project is using. Navigate to File -> Settings -> Go -> GOPATH

Now let's get the build flags for our TinyGo compiler. Do this by running the command tinygo info -target arduino ( Swap out arduino if using another board)

In Goland once again navigate to File -> Settings -> Go -> Build Tags & Vendoring. Update the build flags which we discovered in the previous command.

Flash to Hardware Device

We can now flash the code to our target device.

  • Determine target port by opening Device Manager -> Ports and check which port your device is connecting on.
  • Place our LED in the 13th PIN on our Arduino board with the negative (shorter) leg placed into the ground pin.
  • Flash using command — tinygo flash -target arduino -port COM5 blinky1/blinky1.go

The LED will illuminate and then extinguish every 5000 milliseconds.

Troubleshooting

Tech Lead | AWS Community Builder | AWS Solutions Architect Pro | Passionate about learning | Languages include Java, Go, Typescript, and more recently Rust