Update examples

This commit is contained in:
Adrian Zankich 2013-12-30 13:56:16 -08:00
parent 2e5c745432
commit 5deff8dfed
4 changed files with 9 additions and 29 deletions

View File

@ -1,7 +1,6 @@
package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot-firmata"
"github.com/hybridgroup/gobot-gpio"
@ -17,27 +16,15 @@ func main() {
led.Name = "led"
led.Pin = "13"
connections := []interface{}{
firmata,
}
devices := []interface{}{
led,
}
work := func() {
gobot.Every("1s", func() {
led.Toggle()
if led.IsOn() {
fmt.Println("On")
} else {
fmt.Println("Off")
}
})
}
robot := gobot.Robot{
Connections: connections,
Devices: devices,
Connections: []gobot.Connection{firmata},
Devices: []gobot.Device{led},
Work: work,
}

View File

@ -14,13 +14,6 @@ func main() {
sphero := gobotSphero.NewSphero(spheroAdaptor)
sphero.Name = "Sphero"
connections := []interface{}{
spheroAdaptor,
}
devices := []interface{}{
sphero,
}
work := func() {
gobot.Every("2s", func() {
sphero.Roll(100, uint16(gobot.Rand(360)))
@ -28,8 +21,8 @@ func main() {
}
robot := gobot.Robot{
Connections: connections,
Devices: devices,
Connections: []gobot.Connection{spheroAdaptor},
Devices: []gobot.Device{sphero},
Work: work,
}

View File

@ -17,7 +17,7 @@ func main() {
gobot.Api(Master)
spheros := map[string]string{
"Sphero-BPO": "127.0.0.1:4560",
"Sphero-BPO": "/dev/rfcomm0",
}
for name, port := range spheros {
@ -35,8 +35,8 @@ func main() {
Master.Robots = append(Master.Robots, gobot.Robot{
Name: name,
Connections: []interface{}{spheroAdaptor},
Devices: []interface{}{sphero},
Connections: []gobot.Connection{spheroAdaptor},
Devices: []gobot.Device{sphero},
Work: work,
Commands: map[string]interface{}{"TurnBlue": TurnBlue},
})

View File

@ -27,8 +27,8 @@ func main() {
master.Robots = append(master.Robots, gobot.Robot{
Name: name,
Connections: []interface{}{spheroAdaptor},
Devices: []interface{}{sphero},
Connections: []gobot.Connection{spheroAdaptor},
Devices: []gobot.Device{sphero},
Work: work,
})
}