2023-05-20 20:25:21 +08:00
|
|
|
//go:build example
|
2017-09-07 13:53:28 +08:00
|
|
|
// +build example
|
2023-05-20 20:25:21 +08:00
|
|
|
|
2017-09-07 13:53:28 +08:00
|
|
|
//
|
|
|
|
// Do not build by default.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2023-05-20 20:25:21 +08:00
|
|
|
"gobot.io/x/gobot/v2"
|
|
|
|
"gobot.io/x/gobot/v2/platforms/dexter/gopigo3"
|
|
|
|
"gobot.io/x/gobot/v2/platforms/raspi"
|
2017-09-07 13:53:28 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2017-09-14 06:55:09 +08:00
|
|
|
raspiAdaptor := raspi.NewAdaptor()
|
2017-10-23 19:15:55 +08:00
|
|
|
gpg3 := gopigo3.NewDriver(raspiAdaptor)
|
2017-09-07 13:53:28 +08:00
|
|
|
|
|
|
|
work := func() {
|
|
|
|
on := uint8(0xFF)
|
|
|
|
gobot.Every(1000*time.Millisecond, func() {
|
2017-10-23 19:15:55 +08:00
|
|
|
err := gpg3.SetLED(gopigo3.LED_EYE_RIGHT, 0x00, 0x00, on)
|
2017-09-07 13:53:28 +08:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2017-10-23 19:15:55 +08:00
|
|
|
err = gpg3.SetLED(gopigo3.LED_EYE_LEFT, ^on, 0x00, 0x00)
|
2017-09-07 13:53:28 +08:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
on = ^on
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-09-26 12:31:32 +08:00
|
|
|
robot := gobot.NewRobot("gopigo3eyeleds",
|
2017-09-14 06:55:09 +08:00
|
|
|
[]gobot.Connection{raspiAdaptor},
|
2017-09-26 12:31:32 +08:00
|
|
|
[]gobot.Device{gpg3},
|
2017-09-07 13:53:28 +08:00
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2024-02-11 22:34:50 +08:00
|
|
|
if err := robot.Start(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2017-09-07 13:53:28 +08:00
|
|
|
}
|