hybridgroup.gobot/examples/chip_drv2605l.go

35 lines
552 B
Go
Raw Permalink Normal View History

// +build example
//
// Do not build by default.
package main
import (
"time"
"gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/i2c"
"gobot.io/x/gobot/platforms/chip"
)
func main() {
board := chip.NewAdaptor()
haptic := i2c.NewDRV2605LDriver(board)
work := func() {
gobot.Every(3*time.Second, func() {
pause := haptic.GetPauseWaveform(50)
haptic.SetSequence([]byte{1, pause, 1, pause, 1})
haptic.Go()
})
}
robot := gobot.NewRobot("DRV2605LBot",
[]gobot.Connection{board},
[]gobot.Device{haptic},
work,
)
robot.Start()
}