2014-10-22 01:15:32 +08:00
|
|
|
/*
|
2014-10-29 05:52:59 +08:00
|
|
|
Package sphero provides the Gobot adaptor and driver for the Sphero.
|
2014-10-22 01:15:32 +08:00
|
|
|
|
|
|
|
Installing:
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
go get gobot.io/x/gobot/platforms/sphero
|
2014-10-22 01:15:32 +08:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2014-10-22 01:30:06 +08:00
|
|
|
package main
|
2014-10-22 01:15:32 +08:00
|
|
|
|
2014-10-22 01:30:06 +08:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
2014-10-22 01:15:32 +08:00
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/platforms/sphero"
|
2014-10-22 01:30:06 +08:00
|
|
|
)
|
2014-10-22 01:15:32 +08:00
|
|
|
|
2014-10-22 01:30:06 +08:00
|
|
|
func main() {
|
2016-10-02 00:52:58 +08:00
|
|
|
adaptor := sphero.NewAdaptor("/dev/rfcomm0")
|
|
|
|
driver := sphero.NewSpheroDriver(adaptor)
|
2014-10-22 01:15:32 +08:00
|
|
|
|
2014-10-22 01:30:06 +08:00
|
|
|
work := func() {
|
|
|
|
gobot.Every(3*time.Second, func() {
|
|
|
|
driver.Roll(30, uint16(gobot.Rand(360)))
|
|
|
|
})
|
|
|
|
}
|
2014-10-22 01:15:32 +08:00
|
|
|
|
2014-10-22 01:30:06 +08:00
|
|
|
robot := gobot.NewRobot("sphero",
|
|
|
|
[]gobot.Connection{adaptor},
|
|
|
|
[]gobot.Device{driver},
|
|
|
|
work,
|
|
|
|
)
|
2014-10-22 01:15:32 +08:00
|
|
|
|
2016-10-19 03:37:10 +08:00
|
|
|
robot.Start()
|
2014-10-22 01:30:06 +08:00
|
|
|
}
|
2014-10-22 01:15:32 +08:00
|
|
|
|
2016-07-14 00:44:47 +08:00
|
|
|
For further information refer to sphero readme:
|
2016-12-21 17:56:01 +08:00
|
|
|
https://github.com/hybridgroup/gobot/blob/master/platforms/sphero/README.md
|
2014-10-22 01:15:32 +08:00
|
|
|
*/
|
2016-12-08 20:24:03 +08:00
|
|
|
package sphero // import "gobot.io/x/gobot/platforms/sphero"
|