mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-04-26 13:48:49 +08:00
30 lines
492 B
Go
30 lines
492 B
Go
![]() |
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
|
||
|
"gobot.io/x/gobot"
|
||
|
"gobot.io/x/gobot/platforms/ble"
|
||
|
"gobot.io/x/gobot/platforms/microbit"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
|
||
|
ubit := microbit.NewTemperatureDriver(bleAdaptor)
|
||
|
|
||
|
work := func() {
|
||
|
ubit.On(microbit.Temperature, func(data interface{}) {
|
||
|
fmt.Println("Temperature", data)
|
||
|
})
|
||
|
}
|
||
|
|
||
|
robot := gobot.NewRobot("thermoBot",
|
||
|
[]gobot.Connection{bleAdaptor},
|
||
|
[]gobot.Device{ubit},
|
||
|
work,
|
||
|
)
|
||
|
|
||
|
robot.Start()
|
||
|
}
|