-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
40 lines (30 loc) · 676 Bytes
/
main.go
File metadata and controls
40 lines (30 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"image/color"
"machine"
"math/rand"
"time"
"tinygo.org/x/drivers/ws2812"
)
var neo = machine.Pin(0x08)
var leds [25]color.RGBA
const blinkyspeed = 100
func main() {
neo.Configure(machine.PinConfig{Mode: machine.PinOutput})
ws := ws2812.New(8)
rg := false
for {
rg = !rg
for i := range leds {
rg = !rg
if rg {
// Alpha channel is not supported by WS2812 so we leave it out
leds[i] = color.RGBA{R: uint8(rand.Intn(64)), G: uint8(rand.Intn(64)), B: uint8(rand.Intn(64))}
} else {
leds[i] = color.RGBA{R: 0x00, G: 0x00, B: 0x00}
}
}
ws.WriteColors(leds[:])
time.Sleep(blinkyspeed * time.Millisecond)
}
}