gobot.io/x/gobot@v1.16.0/examples/raspi_grove_pi_blink.go (about) 1 // +build example 2 // 3 // Do not build by default. 4 5 package main 6 7 import ( 8 "time" 9 10 "gobot.io/x/gobot" 11 "gobot.io/x/gobot/drivers/gpio" 12 "gobot.io/x/gobot/drivers/i2c" 13 "gobot.io/x/gobot/platforms/raspi" 14 ) 15 16 func main() { 17 r := raspi.NewAdaptor() 18 gp := i2c.NewGrovePiDriver(r) 19 led := gpio.NewLedDriver(gp, "D2") 20 21 work := func() { 22 gobot.Every(1*time.Second, func() { 23 led.Toggle() 24 }) 25 } 26 27 robot := gobot.NewRobot("blinkBot", 28 []gobot.Connection{r}, 29 []gobot.Device{gp, led}, 30 work, 31 ) 32 33 robot.Start() 34 }