1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-06 19:29:15 +08:00

31 lines
558 B
Go
Raw Normal View History

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