2017-04-15 23:07:53 +08:00
|
|
|
// +build example
|
|
|
|
//
|
|
|
|
// Do not build by default.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/drivers/gpio"
|
|
|
|
"gobot.io/x/gobot/platforms/ble"
|
|
|
|
"gobot.io/x/gobot/platforms/microbit"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
|
|
|
|
|
|
|
|
ubit := microbit.NewIOPinDriver(bleAdaptor)
|
|
|
|
led := gpio.NewLedDriver(ubit, "0")
|
|
|
|
|
|
|
|
work := func() {
|
|
|
|
gobot.Every(1*time.Second, func() {
|
|
|
|
led.Toggle()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("bot",
|
2017-04-16 00:42:37 +08:00
|
|
|
[]gobot.Connection{bleAdaptor},
|
2017-04-15 23:07:53 +08:00
|
|
|
[]gobot.Device{ubit, led},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
robot.Start()
|
|
|
|
}
|