gobot.io/x/gobot@v1.16.0/examples/joule_rgb_led.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/platforms/intel-iot/joule" 13 ) 14 15 func main() { 16 e := joule.NewAdaptor() 17 led := gpio.NewRgbLedDriver(e, "25", "27", "29") 18 19 work := func() { 20 gobot.Every(1*time.Second, func() { 21 r := uint8(gobot.Rand(255)) 22 g := uint8(gobot.Rand(255)) 23 b := uint8(gobot.Rand(255)) 24 led.SetRGB(r, g, b) 25 }) 26 } 27 28 robot := gobot.NewRobot("rgbBot", 29 []gobot.Connection{e}, 30 []gobot.Device{led}, 31 work, 32 ) 33 34 robot.Start() 35 }