Created
November 1, 2019 06:19
-
-
Save mattetti/0c398dad0c12ee4f2a7b61d6c2009d3e to your computer and use it in GitHub Desktop.
Revisions
-
mattetti created this gist
Nov 1, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ // wiring: See https://github.com/tinygo-org/tinygo/blob/master/src/machine/board_arduino_nano33.go#L120 // MOSI / Data on port A3 // Clock on port A2 // power VUSB // ground package main import ( "machine" "time" "image/color" "tinygo.org/x/drivers/apa102" ) func main() { machine.SPI0.Configure(machine.SPIConfig{ Frequency: 500000, Mode: 0}) a := apa102.New(machine.SPI0) leds := make([]color.RGBA, 8) rg := false for { rg = !rg for i := range leds { rg = !rg if rg { leds[i] = color.RGBA{R: 0xff, G: 0x00, B: 0x00, A: 0x77} } else { leds[i] = color.RGBA{R: 0x00, G: 0xff, B: 0x00, A: 0x77} } } a.WriteColors(leds) time.Sleep(100 * time.Millisecond) } } // tinygo flash -target=arduino-nano33 -port=/dev/tty.usbmodem14301