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