add m5atom test with rgb led
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
module m5stickc
|
||||||
|
|
||||||
|
go 1.26.2
|
||||||
|
|
||||||
|
require tinygo.org/x/drivers v0.34.0
|
||||||
|
|
||||||
|
require github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||||||
|
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||||
|
tinygo.org/x/drivers v0.34.0 h1:lw8ePJeUSn9oICKBvQXHC9TIE+J00OfXfkGTrpXM9Iw=
|
||||||
|
tinygo.org/x/drivers v0.34.0/go.mod h1:ZdErNrApSABdVXjA1RejD67R8SNRI6RKVfYgQDZtKtk=
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"image/color"
|
||||||
|
"machine"
|
||||||
|
|
||||||
|
"tinygo.org/x/drivers/ws2812"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
buttonA := machine.GPIO39
|
||||||
|
buttonA.Configure(machine.PinConfig{Mode: machine.PinInput})
|
||||||
|
|
||||||
|
ledPin := machine.GPIO27
|
||||||
|
ledPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||||
|
|
||||||
|
rgbLed := ws2812.NewSK6812(ledPin)
|
||||||
|
|
||||||
|
for {
|
||||||
|
|
||||||
|
valueA := buttonA.Get()
|
||||||
|
if !valueA {
|
||||||
|
rgbLed.WriteColors([]color.RGBA{
|
||||||
|
{R: 61, G: 229, B: 201, A: 255},
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
rgbLed.WriteColors([]color.RGBA{
|
||||||
|
{R: 0, G: 0, B: 0, A: 255},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
fmt.Printf("Button A: %v\n", valueA)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user