gobot.io/x/gobot@v1.16.0/examples/chip_drv2605l.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/i2c"
    12  	"gobot.io/x/gobot/platforms/chip"
    13  )
    14  
    15  func main() {
    16  	board := chip.NewAdaptor()
    17  	haptic := i2c.NewDRV2605LDriver(board)
    18  
    19  	work := func() {
    20  		gobot.Every(3*time.Second, func() {
    21  			pause := haptic.GetPauseWaveform(50)
    22  			haptic.SetSequence([]byte{1, pause, 1, pause, 1})
    23  			haptic.Go()
    24  		})
    25  	}
    26  
    27  	robot := gobot.NewRobot("DRV2605LBot",
    28  		[]gobot.Connection{board},
    29  		[]gobot.Device{haptic},
    30  		work,
    31  	)
    32  
    33  	robot.Start()
    34  }