docs: add examples for i2c platforms to use BlinkM
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
205f7186c6
commit
3e9250c585
|
@ -14,7 +14,7 @@ func main() {
|
|||
blinkm := i2c.NewBlinkMDriver(beagleboneAdaptor)
|
||||
|
||||
work := func() {
|
||||
gobot.Every(3*time.Second, func() {
|
||||
gobot.Every(1*time.Second, func() {
|
||||
r := byte(gobot.Rand(255))
|
||||
g := byte(gobot.Rand(255))
|
||||
b := byte(gobot.Rand(255))
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"gobot.io/x/gobot"
|
||||
"gobot.io/x/gobot/drivers/i2c"
|
||||
"gobot.io/x/gobot/platforms/chip"
|
||||
)
|
||||
|
||||
func main() {
|
||||
a := chip.NewAdaptor()
|
||||
blinkm := i2c.NewBlinkMDriver(a)
|
||||
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
robot := gobot.NewRobot("blinkmBot",
|
||||
[]gobot.Connection{a},
|
||||
[]gobot.Device{blinkm},
|
||||
work,
|
||||
)
|
||||
|
||||
robot.Start()
|
||||
}
|
|
@ -14,7 +14,7 @@ func main() {
|
|||
blinkm := i2c.NewBlinkMDriver(r)
|
||||
|
||||
work := func() {
|
||||
gobot.Every(3*time.Second, func() {
|
||||
gobot.Every(1*time.Second, func() {
|
||||
r := byte(gobot.Rand(255))
|
||||
g := byte(gobot.Rand(255))
|
||||
b := byte(gobot.Rand(255))
|
||||
|
|
Loading…
Reference in New Issue