2013-11-14 12:49:57 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2013-12-03 16:48:20 +08:00
|
|
|
"github.com/hybridgroup/gobot"
|
2013-12-04 08:11:24 +08:00
|
|
|
"github.com/hybridgroup/gobot-sphero"
|
2013-11-14 12:49:57 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
spheroAdaptor := new(gobotSphero.SpheroAdaptor)
|
|
|
|
spheroAdaptor.Name = "Sphero"
|
2013-12-04 08:11:24 +08:00
|
|
|
spheroAdaptor.Port = "/dev/rfcomm0"
|
2013-11-14 12:49:57 +08:00
|
|
|
|
|
|
|
sphero := gobotSphero.NewSphero(spheroAdaptor)
|
|
|
|
sphero.Name = "Sphero"
|
|
|
|
|
|
|
|
work := func() {
|
|
|
|
gobot.Every("2s", func() {
|
2013-12-04 08:11:24 +08:00
|
|
|
sphero.Roll(100, uint16(gobot.Rand(360)))
|
2013-11-14 12:49:57 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.Robot{
|
2013-12-31 05:56:16 +08:00
|
|
|
Connections: []gobot.Connection{spheroAdaptor},
|
|
|
|
Devices: []gobot.Device{sphero},
|
2013-11-14 12:49:57 +08:00
|
|
|
Work: work,
|
|
|
|
}
|
|
|
|
|
|
|
|
robot.Start()
|
|
|
|
}
|