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