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