hybridgroup.gobot/examples/raspi_blink.go

33 lines
479 B
Go

package main
import (
"time"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/drivers/gpio"
"github.com/hybridgroup/gobot/platforms/raspi"
)
func main() {
gbot := gobot.NewMaster()
r := raspi.NewAdaptor()
led := gpio.NewLedDriver(r, "7")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{r},
[]gobot.Device{led},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}