1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-26 13:48:49 +08:00
hybridgroup.gobot/examples/pebble_accelerometer.go

28 lines
633 B
Go
Raw Normal View History

package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/api"
"github.com/hybridgroup/gobot/platforms/pebble"
)
func main() {
master := gobot.NewGobot()
2014-06-10 15:16:11 -07:00
api.NewAPI(master).Start()
pebbleAdaptor := pebble.NewPebbleAdaptor("pebble")
pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble")
work := func() {
gobot.On(pebbleDriver.Events["accel"], func(data interface{}) {
fmt.Println(data.(string))
})
}
robot := gobot.NewRobot("pebble", []gobot.Connection{pebbleAdaptor}, []gobot.Device{pebbleDriver}, work)
master.Robots = append(master.Robots, robot)
master.Start()
}