- Adafruit's PyBadge
- Personal computer with Go 1.13+ and TinyGo installed, and a serial port.
If somehow you have not installed Go 1.13 on your computer already, you can download it here:
Now you are ready to install TinyGo.
Follow the instructions here for your operating system:
https://tinygo.org/getting-started/
Once you have finished installing TinyGo itself, install the drivers needed for the
To install the various drivers and other code dependencies run these commands:
go get -u tinygo.org/x/drivers
go get -u github.com/conejoninja/tinydraw
go get -u github.com/conejoninja/tinyfont
In order to "flash", meaning to move the binary code from your computer to the PyBadge, you must install the "bossac" command line utility which is part of BOSSA.
On Linux, install from source:
sudo apt install \
libwxgtk3.0-dev \
libreadline-dev
git clone https://github.com/shumatech/BOSSA.git
cd BOSSA
make
Install Clang-8:
sudo apt install clang-8
On macOS, you can install it via brew cask install bossa or download the installer from https://github.com/shumatech/BOSSA/releases/download/1.9.1/bossa-1.9.1.dmg
One you have downloaded it, double click on the .dmg file to perform the installation.
-
You must install the "BOSSA" flashing utility first. You can download it from https://github.com/shumatech/BOSSA/releases/download/1.9.1/bossa-x64-1.9.1.msi
-
During the installation, you should choose to put it into
c:\Program Files -
After the installation, you must add it to your PATH:
set PATH=%PATH%;"c:\Program Files\BOSSA";
-
Test that you have installed "BOSSA" correctly by running this command:
bossac --help
Plug the PyBadge into your computer using a USB cable. There may be one provided in your starter kit.
The TinyGo programs will run directly on the PyBadge's microcontoller. The procedure is basically:
- Edit your TinyGo program.
- Compile and flash it to your PyBadge.
- The program executes from the PyBadge. You can disconnect the PyBadge from your computer and plug it into a battery if you wish, the program executes directly on the microcontroller.
Let's get started!
The Linux and macOS device subsystems have subtle differences. In order to talk to the PyBadge board on a Mac, you need to discover how macOS system has named it. Plug it in and follow these commands:
ls /dev | grep usb
Should produce entries like (you may have different numbers after
usbmodem):
/dev/cu.usbmodem141201
/dev/tty.usbmodem141201
Set the fully qualified path for the tty entry into an environment variable. We'll use this below in the macOS version of the steps.
export PYBADGE_DEV_PATH=/dev/{YOUR TTY USBMODEM ID}This tests that you can compile and flash your PyBadge with TinyGo code, by blinking the built-in LED (it's on the back).
- Click on the "RST" button two times to put the PyBadge into bootloader mode so you can load your own code onto it. The front neopixels will lit green and the screen will show a message to indicate that the PyBadge is ready to receive your code.
Run the following command to compile your code, and flash it onto the PyBadge:
tinygo flash -target pybadge ./step0/main.go
tinygo flash -target pybadge -port=$PYBADGE_DEV_PATH ./step0/main.go
tinygo build -o arcade.uf2 -target pybadge -port=$PYBADGE_DEV_PATH ./step0/main.go
And then move the arcade.uf2 file to the PYBADGEBOOT drive.
Once the PyBadge is flashed correctly, the built-in LED labeled "D13" (on the back) should start to turn on and off once per second. Now everything is setup correctly and you are ready to continue.
Run the code.
tinygo flash -target pybadge ./step1/main.go
tinygo flash -target pybadge -port=$PYBADGE_DEV_PATH ./step1/main.go
tinygo build -o arcade.uf2 -target pybadge -port=$PYBADGE_DEV_PATH ./step1/main.go
And then move the arcade.uf2 file to the PYBADGEBOOT drive.
When you press the START button, the built-in LED should turn on.
Run the code.
tinygo flash -target pybadge ./step2/main.go
tinygo flash -target pybadge -port=$PYBADGE_DEV_PATH ./step2/main.go
tinygo build -o arcade.uf2 -target pybadge -port=$PYBADGE_DEV_PATH ./step2/main.go
And then move the arcade.uf2 file to the PYBADGEBOOT drive.
The 5 neopixels should light up green and red alternatively.
Run the code.
tinygo flash -target pybadge ./step3/main.go
tinygo flash -target pybadge -port=$PYBADGE_DEV_PATH ./step3/main.go
tinygo build -o arcade.uf2 -target pybadge -port=$PYBADGE_DEV_PATH ./step3/main.go
And then move the arcade.uf2 file to the PYBADGEBOOT drive.
The 5 neopixels should light up in different colors depending on which button you press.
Run the code.
tinygo flash -target pybadge ./step4/main.go
tinygo flash -target pybadge -port=$PYBADGE_DEV_PATH ./step4/main.go
tinygo build -o arcade.uf2 -target pybadge -port=$PYBADGE_DEV_PATH ./step4/main.go
And then move the arcade.uf2 file to the PYBADGEBOOT drive.
The neopixels will should lit green, they will turn red if not enough light is reaching the sensor A7 (on top of display). If there's no enough light in the room, try using your smartphone's torch to illuminate it a little bit.
Run the code.
tinygo flash -target pybadge ./step5/main.go
tinygo flash -target pybadge -port=$PYBADGE_DEV_PATH ./step5/main.go
tinygo build -o arcade.uf2 -target pybadge -port=$PYBADGE_DEV_PATH ./step5/main.go
And then move the arcade.uf2 file to the PYBADGEBOOT drive.
The message "Hello Gophers!" should appear on the display.
Run the code.
tinygo flash -target pybadge ./step6/main.go
tinygo flash -target pybadge -port=$PYBADGE_DEV_PATH ./step6/main.go
tinygo build -o arcade.uf2 -target pybadge -port=$PYBADGE_DEV_PATH ./step6/main.go
And then move the arcade.uf2 file to the PYBADGEBOOT drive.
The display will show some blue circles. When a button is pressed a ring will be shown around its corresponding circle.
Run the code.
tinygo flash -target pybadge ./step7/main.go
tinygo flash -target pybadge -port=$PYBADGE_DEV_PATH ./step7/main.go
tinygo build -o arcade.uf2 -target pybadge -port=$PYBADGE_DEV_PATH ./step7/main.go
And then move the arcade.uf2 file to the PYBADGEBOOT drive.
The display will show a bar for each X,Y,Z axis. Move the Pybadge to see it in action.
Run the code.
tinygo flash -target pybadge ./step8/main.go
tinygo flash -target pybadge -port=$PYBADGE_DEV_PATH ./step8/main.go
tinygo build -o arcade.uf2 -target pybadge -port=$PYBADGE_DEV_PATH ./step8/main.go
And then move the arcade.uf2 file to the PYBADGEBOOT drive.
Press the buttons and create your melody.
Run the code.
tinygo flash -target pybadge ./snake/main.go
tinygo flash -target pybadge -port=$PYBADGE_DEV_PATH ./snake/main.go
tinygo build -o arcade.uf2 -target pybadge -port=$PYBADGE_DEV_PATH ./snake/main.go
And then move the arcade.uf2 file to the PYBADGEBOOT drive.
Play the famous Snake game on the pybadge.
Run the code.
tinygo flash -target pybadge ./mynameis/main.go
tinygo flash -target pybadge -port=$PYBADGE_DEV_PATH ./mynameis/main.go
tinygo build -o arcade.uf2 -target pybadge -port=$PYBADGE_DEV_PATH ./mynameis/main.go
And then move the arcade.uf2 file to the PYBADGEBOOT drive.
Configure your name and use the awesome TinyGo-powered badge!





