Update examples
This commit is contained in:
parent
2e5c745432
commit
5deff8dfed
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
@ -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},
|
||||
})
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue