gobot.io/x/gobot/v2@v2.1.0/examples/edison_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/platforms/intel-iot/edison"
    15  )
    16  
    17  const boardType = "arduino" // "sparkfun" for a Sparkfun Edison board with the GPIO block
    18  
    19  func main() {
    20  	e := edison.NewAdaptor(boardType)
    21  	led := gpio.NewLedDriver(e, "13")
    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  }