mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-04-29 13:49:14 +08:00
30 lines
451 B
Go
30 lines
451 B
Go
![]() |
package main
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"time"
|
||
|
|
||
|
"gobot.io/x/gobot"
|
||
|
"gobot.io/x/gobot/drivers/gpio"
|
||
|
"gobot.io/x/gobot/platforms/firmata"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
firmataAdaptor := firmata.NewTCPAdaptor(os.Args[1])
|
||
|
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,
|
||
|
)
|
||
|
|
||
|
robot.Start()
|
||
|
}
|