mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-04-29 13:49:14 +08:00
33 lines
522 B
Go
33 lines
522 B
Go
package main
|
|
|
|
import (
|
|
"github.com/hybridgroup/gobot"
|
|
"github.com/hybridgroup/gobot/firmata"
|
|
"github.com/hybridgroup/gobot/gpio"
|
|
)
|
|
|
|
func main() {
|
|
|
|
firmata := new(firmata.Adaptor)
|
|
firmata.Name = "firmata"
|
|
firmata.Port = "/dev/ttyACM0"
|
|
|
|
led := gpio.NewLed(firmata)
|
|
led.Name = "led"
|
|
led.Pin = "13"
|
|
|
|
work := func() {
|
|
gobot.Every("1s", func() {
|
|
led.Toggle()
|
|
})
|
|
}
|
|
|
|
robot := gobot.Robot{
|
|
Connections: []gobot.Connection{firmata},
|
|
Devices: []gobot.Device{led},
|
|
Work: work,
|
|
}
|
|
|
|
robot.Start()
|
|
}
|