Gopherbot is a robot gopher plushie that is programmable using TinyGo (https://tinygo.org)
Uses an Adafruit Circuit Playground Express with a 3D printed helmet and backpack.
Here is a TinyGo program that blinks all of the various built-in LEDs all at the same time when the slider switch is in the "on" position.
package main
import (
"time"
"github.com/axiomista/gopherbot"
)
func main() {
led := gopherbot.StatusLED()
antenna := gopherbot.Antenna()
visor := gopherbot.Visor()
backpack := gopherbot.Backpack()
slider := gopherbot.Slider()
for {
if slider.IsOn() {
led.On()
antenna.On()
visor.Blue()
backpack.Blue()
time.Sleep(500 * time.Millisecond)
led.Off()
antenna.Off()
visor.Off()
backpack.Off()
time.Sleep(500 * time.Millisecond)
}
}
}
Did you receive a Gopherbot kit? Awesome! For assembly instructions, go here:
Gopherbot Assembly Instructions
To put code on Gopherbot, you need to install some software on your own machine.
If you have not installed Go 1.12 on your computer already, you can download it here:
Follow the instructions here to install TinyGo:
https://tinygo.org/getting-started/
To install the various drivers and other code dependencies run this command:
go get -u tinygo.org/x/drivers
Lastly, get the code from this repository:
git clone https://github.com/axiomista/gopherbot.git
cd gopherbot
OK great, we're ready to write our first TinyGo program and put it on Gopherbot.
Gopherbot uses an Adafruit Circuit Playground Express as its "brain". To put new code on the Circuit Playground Express you can copy a file in the correct format from your computer to the board using a USB connection without having to install any extra flashing software. This is because it comes with a "bootloader" named UF2 already installed, that lets to do the flashing. Here is more information about the UF2 bootloader if you are interested.
Here is what to do:
- Plug your Circuit Playground Express into your computer's USB port.
- Press the "RESET" button on the board two times to get the Circuit Playground Express board ready to receive code. You have to do this every time you want to put new code on to the board.
- The Circuit Playground Express board will appear to your computer like a USB drive. Determine the path to the board:
On Linux it will be something like /media/[USERNAME]/[NAME OF THE BOARD]
On OSX you'll probably see /Volumes/[NAME OF THE BOARD]
Build your TinyGo program to the board in .uf2
format using this command:
tinygo build -size short -o /media/yourname/CPLAYBOOT/flash.uf2 -target=circuitplay-express examples/blinky1
- The Circuit Playground Express board should restart and then begin running your program. This program just causes the small LED labelled "D13" on the Circuit Playground Express board to start blinking on and off.
Now you are ready to try something a little more flashy.
- Once again, press the "RESET" button on the board two times to get the Circuit Playground Express board ready to receive code.
- Build the demo TinyGo program to the board in format using this command:
tinygo build -size short -o /media/yourname/CPLAYBOOT/flash.uf2 -target=circuitplay-express ./examples/blink/main.go
Now THAT is a blink!
If you want to load one of the example programs on Gopherbot, check out our examples located here.
For a series of activities to learn programming TinyGo using Gopherbot, check out the learn folder.
Have fun!