34 lines
610 B
Go
34 lines
610 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
"github.com/hybridgroup/gobot/platforms/gpio"
|
|
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
|
|
)
|
|
|
|
func main() {
|
|
gbot := gobot.NewGobot()
|
|
|
|
board := edison.NewEdisonAdaptor("board")
|
|
sensor := gpio.NewGroveTemperatureSensorDriver(board, "sensor", "0")
|
|
|
|
work := func() {
|
|
gobot.Every(500*time.Millisecond, func() {
|
|
fmt.Println("current temp (c): ", sensor.Temperature())
|
|
})
|
|
}
|
|
|
|
robot := gobot.NewRobot("sensorBot",
|
|
[]gobot.Connection{board},
|
|
[]gobot.Device{sensor},
|
|
work,
|
|
)
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
gbot.Start()
|
|
}
|