39 lines
697 B
Go
39 lines
697 B
Go
package main
|
|
|
|
import (
|
|
"github.com/hybridgroup/gobot"
|
|
"github.com/hybridgroup/gobot/gpio"
|
|
"github.com/hybridgroup/gobot/spark"
|
|
)
|
|
|
|
func main() {
|
|
master := gobot.NewMaster()
|
|
gobot.Api(master)
|
|
|
|
sparkCore := spark.NewSparkCoreAdaptor()
|
|
sparkCore.Name = "spark"
|
|
sparkCore.Params = map[string]interface{}{
|
|
"device_id": "",
|
|
"access_token": "",
|
|
}
|
|
|
|
led := gpio.NewLed(sparkCore)
|
|
led.Name = "led"
|
|
led.Pin = "D7"
|
|
|
|
work := func() {
|
|
gobot.Every("1s", func() {
|
|
led.Toggle()
|
|
})
|
|
}
|
|
|
|
master.Robots = append(master.Robots, &gobot.Robot{
|
|
Name: "spark",
|
|
Connections: []gobot.Connection{sparkCore},
|
|
Devices: []gobot.Device{led},
|
|
Work: work,
|
|
})
|
|
|
|
master.Start()
|
|
}
|