liveBook · Manning

TinyGo playground

As explained in Learn Go with Pocket-Sized Projects

TinyGo playground is a web-based environment for compiling and simulating TinyGo programs on virtual microcontroller boards.

No microcontroller board? Use the TinyGo playground at https://play.tinygo.org/ to flash a virtual one. It compiles TinyGo programs using Wasm and simulates connected LEDs, so you can try a circuit without physical components or resistors. section 12.3

To try a program:

  • Select a virtual microcontroller, paste the code, and click Flash. section 12.3.1
  • Watch the simulated output. On an Arduino Nano 33 IoT, its orange LED appears below the USB port. section 12.3.1
  • Switch boards and flash again to check portability. The LED example does not blink on a Phytec reel board because machine.LED is not defined there. section 12.3.1

Blink the virtual board LED

Select Arduino Nano 33 IoT and flash this program: package main import ( "machine" "time" ) func main() { led := machine.LED led.Configure(machine.PinConfig{Mode: machine.PinOutput}) for { led.High() time.Sleep(time.Second / 2) led.Low() time.Sleep(time.Second / 2) } } Configuring the pin as an output lets High and Low control it. The loop keeps the simulated LED blinking. section 12.3.1

Figure 12.6 Electrical schema from the TinyGo playground using an Arduino Nano 33 IoT
A diagram of a car light

Description automatically generated

The Arduino Nano 33 IoT electrical schema shows how a playground project can extend beyond the board’s built-in LED to connected traffic-light LEDs. section 12.3.1

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Walks through selecting a board, flashing code, and observing output; leaves real-device flashing for a separate procedure.
Examples
Uses a blinking Arduino Nano 33 IoT LED and a board switch that stops the example from blinking.
What it assumes
Assumes familiarity with Go code while requiring no physical microcontroller board.
What you can do after
Operate/configure it by selecting a virtual board, pasting TinyGo code, and clicking Flash to inspect simulated LEDs.
How it connects
Connects TinyGo flashing with microcontroller boards, GPIO output pins, LEDs, and board-specific pin definitions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Go with Pocket-Sized Projects. The section links point to the parts of the book it draws on.