29 lines
461 B
Go
29 lines
461 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gobot.io/x/gobot"
|
|
"gobot.io/x/gobot/drivers/gpio"
|
|
"gobot.io/x/gobot/platforms/intel-iot/edison"
|
|
)
|
|
|
|
func main() {
|
|
board := edison.NewAdaptor()
|
|
sensor := gpio.NewGroveSoundSensorDriver(board, "0")
|
|
|
|
work := func() {
|
|
sensor.On(gpio.Data, func(data interface{}) {
|
|
fmt.Println("sensor", data)
|
|
})
|
|
}
|
|
|
|
robot := gobot.NewRobot("sensorBot",
|
|
[]gobot.Connection{board},
|
|
[]gobot.Device{sensor},
|
|
work,
|
|
)
|
|
|
|
robot.Start()
|
|
}
|