37 lines
574 B
Go
37 lines
574 B
Go
|
// +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",
|
||
|
[]gobot.Connection{bleAdaptor, ubit},
|
||
|
[]gobot.Device{ubit, led},
|
||
|
work,
|
||
|
)
|
||
|
|
||
|
robot.Start()
|
||
|
}
|