gobot.io/x/gobot@v1.16.0/examples/audio.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/platforms/audio" 12 ) 13 14 func main() { 15 e := audio.NewAdaptor() 16 laser := audio.NewDriver(e, "./examples/laser.mp3") 17 18 work := func() { 19 gobot.Every(2*time.Second, func() { 20 laser.Play() 21 }) 22 } 23 24 robot := gobot.NewRobot("soundBot", 25 []gobot.Connection{e}, 26 []gobot.Device{laser}, 27 work, 28 ) 29 30 robot.Start() 31 }