2023-05-20 14:25:21 +02:00
|
|
|
//go:build example
|
2017-03-13 11:01:39 -04:00
|
|
|
// +build example
|
2023-05-20 14:25:21 +02:00
|
|
|
|
2017-03-13 11:01:39 -04:00
|
|
|
//
|
|
|
|
// Do not build by default.
|
|
|
|
|
2016-05-13 16:09:36 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2023-05-20 14:25:21 +02:00
|
|
|
"gobot.io/x/gobot/v2"
|
|
|
|
"gobot.io/x/gobot/v2/platforms/audio"
|
2016-05-13 16:09:36 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-09-25 12:17:01 +02:00
|
|
|
e := audio.NewAdaptor()
|
|
|
|
laser := audio.NewDriver(e, "./examples/laser.mp3")
|
2016-05-13 16:09:36 -07:00
|
|
|
|
|
|
|
work := func() {
|
2016-05-24 21:05:27 -07:00
|
|
|
gobot.Every(2*time.Second, func() {
|
2016-05-24 21:01:16 -07:00
|
|
|
laser.Play()
|
2016-05-13 16:09:36 -07:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("soundBot",
|
|
|
|
[]gobot.Connection{e},
|
|
|
|
[]gobot.Device{laser},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2024-02-11 15:34:50 +01:00
|
|
|
if err := robot.Start(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2016-05-13 16:09:36 -07:00
|
|
|
}
|