2014-04-28 10:56:18 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hybridgroup/gobot"
|
2014-04-30 23:10:44 +08:00
|
|
|
"github.com/hybridgroup/gobot/platforms/firmata"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/gpio"
|
2014-04-28 10:56:18 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-04-30 23:10:44 +08:00
|
|
|
gbot := gobot.NewGobot()
|
2014-04-28 10:56:18 +08:00
|
|
|
|
2014-04-30 23:10:44 +08:00
|
|
|
firmataAdaptor := firmata.NewFirmataAdaptor("myFirmata", "/dev/ttyACM0")
|
|
|
|
|
|
|
|
led := gpio.NewLedDriver(firmataAdaptor, "myLed", "13")
|
2014-04-28 10:56:18 +08:00
|
|
|
|
|
|
|
work := func() {
|
|
|
|
gobot.Every("1s", func() {
|
|
|
|
led.Toggle()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-04-30 23:10:44 +08:00
|
|
|
gbot.Robots = append(gbot.Robots, gobot.NewRobot("Jerry", []gobot.Connection{firmataAdaptor}, []gobot.Device{led}, work))
|
|
|
|
gbot.Start()
|
2014-04-28 10:56:18 +08:00
|
|
|
}
|