Added simple example for DRV2605L on C.H.I.P

Signed-off-by: Erik Agsjö <erik.agsjo@gmail.com>
This commit is contained in:
Erik Agsjö 2017-02-21 22:53:43 +01:00
parent 9b0425480d
commit a144fd6ebe
1 changed files with 30 additions and 0 deletions

30
examples/chip_drv2605l.go Normal file
View File

@ -0,0 +1,30 @@
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()
}