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