hybridgroup.gobot/examples/spark_core_blink.go

35 lines
592 B
Go
Raw Normal View History

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"
)
func main() {
2014-04-28 02:56:23 +08:00
sparkCore := spark.NewSparkCoreAdaptor()
sparkCore.Name = "spark"
sparkCore.Params = map[string]interface{}{
"device_id": "",
"access_token": "",
}
2014-04-28 02:56:23 +08:00
led := gpio.NewLed(sparkCore)
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},
Devices: []gobot.Device{led},
Work: work,
}
robot.Start()
}