diff --git a/m5atom/go.mod b/m5atom/go.mod new file mode 100644 index 0000000..0f38843 --- /dev/null +++ b/m5atom/go.mod @@ -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 diff --git a/m5atom/go.sum b/m5atom/go.sum new file mode 100644 index 0000000..a1c68f7 --- /dev/null +++ b/m5atom/go.sum @@ -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= diff --git a/m5atom/main.go b/m5atom/main.go new file mode 100644 index 0000000..a281233 --- /dev/null +++ b/m5atom/main.go @@ -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) + } +}