1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-11 19:29:20 +08:00
2014-07-07 17:37:53 -07:00
..
2014-04-29 13:20:32 -07:00
2014-06-09 19:01:53 -07:00
2014-07-07 17:37:53 -07:00

Spark

This package provides the Gobot adaptor for the Spark Core

Installing

go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/platforms/spark

Example

package main

import (
        "github.com/hybridgroup/gobot"
        "github.com/hybridgroup/gobot/platforms/gpio"
        "github.com/hybridgroup/gobot/platforms/spark"
        "time"
)

func main() {
        master := gobot.NewGobot()

        sparkCore := spark.NewSparkCoreAdaptor("spark", "device_id", "access_token")
        led := gpio.NewLedDriver(sparkCore, "led", "D7")

        work := func() {
                gobot.Every(1*time.Second, func() {
                        led.Toggle()
                })
        }

        master.Robots = append(master.Robots,
                gobot.NewRobot("spark", []gobot.Connection{sparkCore}, []gobot.Device{led}, work))

        master.Start()
}