2014-04-27 19:56:18 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2014-07-09 16:51:00 -07:00
|
|
|
"time"
|
|
|
|
|
2014-04-27 19:56:18 -07:00
|
|
|
"github.com/hybridgroup/gobot"
|
2014-04-30 08:10:44 -07:00
|
|
|
"github.com/hybridgroup/gobot/platforms/firmata"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/gpio"
|
2014-04-27 19:56:18 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-04-30 08:10:44 -07:00
|
|
|
gbot := gobot.NewGobot()
|
2014-07-08 18:36:14 -07:00
|
|
|
|
|
|
|
firmataAdaptor := firmata.NewFirmataAdaptor("arduino", "/dev/ttyACM0")
|
2014-07-09 16:51:00 -07:00
|
|
|
led := gpio.NewLedDriver(firmataAdaptor, "led", "13")
|
2014-07-08 18:36:14 -07:00
|
|
|
|
|
|
|
work := func() {
|
2014-05-22 19:22:14 -07:00
|
|
|
gobot.Every(1*time.Second, func() {
|
2014-07-08 18:36:14 -07:00
|
|
|
led.Toggle()
|
2014-04-27 19:56:18 -07:00
|
|
|
})
|
|
|
|
}
|
2014-07-08 18:36:14 -07:00
|
|
|
|
|
|
|
robot := gobot.NewRobot("bot",
|
|
|
|
[]gobot.Connection{firmataAdaptor},
|
|
|
|
[]gobot.Device{led},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
2014-04-30 08:10:44 -07:00
|
|
|
gbot.Start()
|
2014-04-27 19:56:18 -07:00
|
|
|
}
|