2016-05-14 07:09:36 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/platforms/audio"
|
2016-05-14 07:09:36 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-09-25 18:17:01 +08:00
|
|
|
e := audio.NewAdaptor()
|
|
|
|
laser := audio.NewDriver(e, "./examples/laser.mp3")
|
2016-05-14 07:09:36 +08:00
|
|
|
|
|
|
|
work := func() {
|
2016-05-25 12:05:27 +08:00
|
|
|
gobot.Every(2*time.Second, func() {
|
2016-05-25 12:01:16 +08:00
|
|
|
laser.Play()
|
2016-05-14 07:09:36 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("soundBot",
|
|
|
|
[]gobot.Connection{e},
|
|
|
|
[]gobot.Device{laser},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2016-10-19 03:08:25 +08:00
|
|
|
robot.Start()
|
2016-05-14 07:09:36 +08:00
|
|
|
}
|