2017-09-06 23:53:28 -06:00
|
|
|
# GoPiGo3
|
|
|
|
|
|
|
|
The GoPiGo3 is a robotics controller by Dexter Industries that is compatible with the Raspberry Pi.
|
|
|
|
|
|
|
|
## How to Install
|
|
|
|
|
2023-06-04 18:36:55 +02:00
|
|
|
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
|
2017-09-06 23:53:28 -06:00
|
|
|
|
|
|
|
## How to Use
|
2023-06-04 18:36:55 +02:00
|
|
|
|
2017-09-06 23:53:28 -06:00
|
|
|
This example will blink the left and right leds red/blue.
|
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-06-04 18:36:55 +02:00
|
|
|
"fmt"
|
|
|
|
"time"
|
2017-09-06 23:53:28 -06:00
|
|
|
|
2023-06-04 18:36:55 +02:00
|
|
|
"gobot.io/x/gobot/v2"
|
|
|
|
g "gobot.io/x/gobot/v2/platforms/dexter/gopigo3"
|
|
|
|
"gobot.io/x/gobot/v2/platforms/raspi"
|
2017-09-06 23:53:28 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-06-04 18:36:55 +02:00
|
|
|
raspiAdaptor := raspi.NewAdaptor()
|
|
|
|
gopigo3 := g.NewDriver(raspiAdaptor)
|
|
|
|
|
|
|
|
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",
|
|
|
|
[]gobot.Connection{raspiAdaptor},
|
|
|
|
[]gobot.Device{gopigo3},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
robot.Start()
|
2017-09-06 23:53:28 -06:00
|
|
|
}
|
2023-06-04 18:36:55 +02:00
|
|
|
```
|