2015-07-10 02:50:39 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/gpio"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
gbot := gobot.NewGobot()
|
|
|
|
|
|
|
|
board := edison.NewEdisonAdaptor("edison")
|
|
|
|
sensor := gpio.NewGrovePiezoVibrationSensorDriver(board, "sensor", "0")
|
|
|
|
|
|
|
|
work := func() {
|
2016-09-01 18:17:43 +08:00
|
|
|
sensor.On(gpio.Vibration, func(data interface{}) {
|
2015-07-10 02:50:39 +08:00
|
|
|
fmt.Println("got one!")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("bot",
|
|
|
|
[]gobot.Connection{board},
|
|
|
|
[]gobot.Device{sensor},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
|
|
|
}
|