hybridgroup.gobot/platforms/sphero/doc.go

47 lines
849 B
Go
Raw Normal View History

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:
2014-10-29 05:52:59 +08:00
go get github.com/hybridgroup/gobot/platforms/sphero
2014-10-22 01:15:32 +08:00
Example:
package main
2014-10-22 01:15:32 +08:00
import (
"fmt"
"time"
2014-10-22 01:15:32 +08:00
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/sphero"
)
2014-10-22 01:15:32 +08:00
func main() {
gbot := gobot.NewGobot()
2014-10-22 01:15:32 +08:00
adaptor := sphero.NewSpheroAdaptor("sphero", "/dev/rfcomm0")
driver := sphero.NewSpheroDriver(adaptor, "sphero")
2014-10-22 01:15:32 +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
robot := gobot.NewRobot("sphero",
[]gobot.Connection{adaptor},
[]gobot.Device{driver},
work,
)
2014-10-22 01:15:32 +08:00
gbot.AddRobot(robot)
2014-10-22 01:15:32 +08:00
gbot.Start()
}
2014-10-22 01:15:32 +08:00
For futher information refer to sphero readme:
https://github.com/hybridgroup/gobot/blob/master/platforms/sphero/README.md
*/
package sphero