1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-29 13:49:14 +08:00
hybridgroup.gobot/examples/sphero_api.go

39 lines
746 B
Go
Raw Normal View History

2013-11-23 10:36:08 -08:00
package main
import (
2013-11-24 14:56:13 -08:00
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot-sphero"
2013-11-23 10:36:08 -08:00
)
func main() {
2013-11-24 16:17:47 -08:00
bot := gobot.GobotMaster()
2013-11-24 14:56:13 -08:00
gobot.Api(bot)
spheros := map[string]string{
"Sphero-BPO": "127.0.0.1:4560",
}
for name, port := range spheros {
spheroAdaptor := new(gobotSphero.SpheroAdaptor)
spheroAdaptor.Name = "sphero"
spheroAdaptor.Port = port
sphero := gobotSphero.NewSphero(spheroAdaptor)
sphero.Name = "sphero"
sphero.Interval = "0.5s"
work := func() {
sphero.SetRGB(uint8(255), uint8(0), uint8(0))
}
bot.Robots = append(bot.Robots, gobot.Robot{
Name: name,
Connections: []interface{}{spheroAdaptor},
Devices: []interface{}{sphero},
Work: work,
})
}
bot.Start()
2013-11-23 10:36:08 -08:00
}