hybridgroup.gobot/examples/sphero.go

38 lines
613 B
Go
Raw Normal View History

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"
connections := []interface{}{
spheroAdaptor,
}
devices := []interface{}{
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{
Connections: connections,
Devices: devices,
Work: work,
}
robot.Start()
}