1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00

47 lines
850 B
Go
Raw Normal View History

2014-10-21 12:15:32 -05:00
/*
2014-10-28 14:52:59 -07:00
Package sphero provides the Gobot adaptor and driver for the Sphero.
2014-10-21 12:15:32 -05:00
Installing:
2014-10-28 14:52:59 -07:00
go get github.com/hybridgroup/gobot/platforms/sphero
2014-10-21 12:15:32 -05:00
Example:
package main
2014-10-21 12:15:32 -05:00
import (
"fmt"
"time"
2014-10-21 12:15:32 -05:00
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/sphero"
)
2014-10-21 12:15:32 -05:00
func main() {
gbot := gobot.NewGobot()
2014-10-21 12:15:32 -05:00
adaptor := sphero.NewSpheroAdaptor("sphero", "/dev/rfcomm0")
driver := sphero.NewSpheroDriver(adaptor, "sphero")
2014-10-21 12:15:32 -05:00
work := func() {
gobot.Every(3*time.Second, func() {
driver.Roll(30, uint16(gobot.Rand(360)))
})
}
2014-10-21 12:15:32 -05:00
robot := gobot.NewRobot("sphero",
[]gobot.Connection{adaptor},
[]gobot.Device{driver},
work,
)
2014-10-21 12:15:32 -05:00
gbot.AddRobot(robot)
2014-10-21 12:15:32 -05:00
gbot.Start()
}
2014-10-21 12:15:32 -05:00
2016-07-13 10:44:47 -06:00
For further information refer to sphero readme:
2014-10-21 12:15:32 -05:00
https://github.com/hybridgroup/gobot/blob/master/platforms/sphero/README.md
*/
package sphero