hybridgroup.gobot/examples/raspi_blink.go

35 lines
472 B
Go
Raw Normal View History

//go:build example
// +build example
//
// Do not build by default.
2014-11-05 09:14:36 +08:00
package main
import (
"time"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/raspi"
2014-11-05 09:14:36 +08:00
)
func main() {
r := raspi.NewAdaptor()
led := gpio.NewLedDriver(r, "7")
2014-11-05 09:14:36 +08:00
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{r},
[]gobot.Device{led},
work,
)
robot.Start()
2014-11-05 09:14:36 +08:00
}