2014-04-26 18:11:51 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hybridgroup/gobot"
|
2014-04-28 02:56:23 +08:00
|
|
|
"github.com/hybridgroup/gobot/gpio"
|
|
|
|
"github.com/hybridgroup/gobot/spark"
|
2014-04-26 18:11:51 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-04-28 02:56:23 +08:00
|
|
|
sparkCore := spark.NewSparkCoreAdaptor()
|
|
|
|
sparkCore.Name = "spark"
|
|
|
|
sparkCore.Params = map[string]interface{}{
|
2014-04-26 18:11:51 +08:00
|
|
|
"device_id": "",
|
|
|
|
"access_token": "",
|
|
|
|
}
|
|
|
|
|
2014-04-28 02:56:23 +08:00
|
|
|
led := gpio.NewLed(sparkCore)
|
2014-04-26 18:11:51 +08:00
|
|
|
led.Name = "led"
|
|
|
|
led.Pin = "D7"
|
|
|
|
|
|
|
|
work := func() {
|
|
|
|
gobot.Every("2s", func() {
|
|
|
|
led.Toggle()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.Robot{
|
2014-04-28 02:56:23 +08:00
|
|
|
Connections: []gobot.Connection{sparkCore},
|
2014-04-26 18:11:51 +08:00
|
|
|
Devices: []gobot.Device{led},
|
|
|
|
Work: work,
|
|
|
|
}
|
|
|
|
|
|
|
|
robot.Start()
|
|
|
|
}
|