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

36 lines
616 B
Go
Raw Normal View History

package main
import (
"fmt"
2014-07-10 17:21:21 -07:00
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/api"
"github.com/hybridgroup/gobot/platforms/pebble"
)
func main() {
gbot := gobot.NewMaster()
a := api.NewAPI(gbot)
a.Port = "8080"
a.Start()
pebbleAdaptor := pebble.NewAdaptor()
pebbleDriver := pebble.NewDriver(pebbleAdaptor)
work := func() {
pebbleDriver.On(pebbleDriver.Event("accel"), func(data interface{}) {
fmt.Println(data.(string))
})
}
2014-07-08 18:36:14 -07:00
robot := gobot.NewRobot("pebble",
[]gobot.Connection{pebbleAdaptor},
[]gobot.Device{pebbleDriver},
work,
)
2014-07-08 18:36:14 -07:00
gbot.AddRobot(robot)
gbot.Start()
}