hybridgroup.gobot/examples/firmata_blink_api.go

36 lines
562 B
Go
Raw Normal View History

package main
import (
"time"
"gobot.io/x/gobot"
"gobot.io/x/gobot/api"
"gobot.io/x/gobot/drivers/gpio"
"gobot.io/x/gobot/platforms/firmata"
)
func main() {
master := gobot.NewMaster()
a := api.NewAPI(master)
a.Start()
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "13")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("bot",
[]gobot.Connection{firmataAdaptor},
[]gobot.Device{led},
work,
)
master.AddRobot(robot)
master.Start()
}