hybridgroup.gobot/examples/gopigo3.go

43 lines
715 B
Go
Raw Normal View History

2017-09-07 13:53:28 +08:00
// +build example
//
// Do not build by default.
package main
import (
"fmt"
"time"
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/dexter/gopigo3"
"gobot.io/x/gobot/platforms/raspi"
2017-09-07 13:53:28 +08:00
)
func main() {
raspiAdaptor := raspi.NewAdaptor()
gpg3 := g.NewDriver(raspiAdaptor)
2017-09-07 13:53:28 +08:00
work := func() {
on := uint8(0xFF)
gobot.Every(1000*time.Millisecond, func() {
err := gpg3.SetLED(g.LED_EYE_RIGHT, 0x00, 0x00, on)
2017-09-07 13:53:28 +08:00
if err != nil {
fmt.Println(err)
}
err = gpg3.SetLED(g.LED_EYE_LEFT, ^on, 0x00, 0x00)
2017-09-07 13:53:28 +08:00
if err != nil {
fmt.Println(err)
}
on = ^on
})
}
robot := gobot.NewRobot("gopigo3eyeleds",
[]gobot.Connection{raspiAdaptor},
[]gobot.Device{gpg3},
2017-09-07 13:53:28 +08:00
work,
)
robot.Start()
}