hybridgroup.gobot/examples/beaglebone_blinkm.go

41 lines
698 B
Go
Raw Normal View History

//go:build example
// +build example
//
// Do not build by default.
package main
import (
"fmt"
2014-07-11 08:21:21 +08:00
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/i2c"
"gobot.io/x/gobot/v2/platforms/beaglebone"
)
func main() {
beagleboneAdaptor := beaglebone.NewAdaptor()
blinkm := i2c.NewBlinkMDriver(beagleboneAdaptor)
work := func() {
gobot.Every(1*time.Second, func() {
r := byte(gobot.Rand(255))
g := byte(gobot.Rand(255))
b := byte(gobot.Rand(255))
blinkm.Rgb(r, g, b)
color, _ := blinkm.Color()
fmt.Println("color", color)
})
}
2014-07-09 09:36:14 +08:00
robot := gobot.NewRobot("blinkmBot",
[]gobot.Connection{beagleboneAdaptor},
[]gobot.Device{blinkm},
work,
)
robot.Start()
}