Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions examples/apa102/blinkt-cylon/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Draws a red Cylon sweep on a Pimoroni Blinkt! connected to the 40 pin
// header of a Waveshare RP2040-PiZero.
// https://shop.pimoroni.com/products/blinkt
package main

import (
"image/color"
"machine"
"time"

"tinygo.org/x/drivers/apa102"
)

const numLEDs = 8

func main() {
// Blinkt! uses BCM23 for data and BCM24 for clock. These are not
// hardware SPI pins on the RP2040, so use software SPI.
leds := apa102.NewSoftwareSPI(machine.GP24, machine.GP23, 1)

var c [numLEDs]color.RGBA
pos, dir := 0, 1
for {
for i := range c {
c[i].R /= 4
c[i].A = 0x20
}
c[pos].R = 0xff
leds.WriteColors(c[:])

if pos+dir < 0 || pos+dir >= numLEDs {
dir = -dir
}
pos += dir
time.Sleep(80 * time.Millisecond)
}
}
Loading