gobot.io/x/gobot@v1.16.0/examples/edison_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/platforms/intel-iot/edison"
    13  )
    14  
    15  func main() {
    16  	e := edison.NewAdaptor()
    17  	led := gpio.NewLedDriver(e, "13")
    18  
    19  	// Uncomment the line below if you are using a Sparkfun
    20  	// Edison board with the GPIO block
    21  	// e.SetBoard("sparkfun")
    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{e},
    31  		[]gobot.Device{led},
    32  		work,
    33  	)
    34  
    35  	robot.Start()
    36  }