33 lines
499 B
Go
33 lines
499 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"github.com/hybridgroup/gobot"
|
||
|
"github.com/hybridgroup/gobot/platforms/gpio"
|
||
|
"github.com/hybridgroup/gobot/platforms/raspi"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
gbot := gobot.NewGobot()
|
||
|
|
||
|
r := raspi.NewRaspiAdaptor("raspi")
|
||
|
led := gpio.NewLedDriver(r, "led", "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()
|
||
|
}
|