hybridgroup.gobot/platforms/spark
deadprogram d884299c90 Merge branch 'master' into dev 2014-12-13 18:46:31 -08:00
..
LICENSE
README.md update readmes for import script 2014-12-12 10:32:52 -08:00
doc.go
spark_core_adaptor.go
spark_core_adaptor_test.go

README.md

Spark

The Spark Core contains a Wi-Fi connected microcontroller. Once it connects to a Wi-Fi network, it automatically connects with a central server (the "Spark Cloud") and stays connected so it can be controlled from external systems, such as a Gobot program. To run gobot programs please make sure you are running default tinker firmware on the Spark Core.

For more info about the Spark platform click here

How to Install

Installing Gobot with Spark support is pretty easy.

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

How to Use

package main

import (
	"time"

	"github.com/hybridgroup/gobot"
	"github.com/hybridgroup/gobot/platforms/gpio"
	"github.com/hybridgroup/gobot/platforms/spark"
)

func main() {
	gbot := 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()
		})
	}

	robot := gobot.NewRobot("spark",
		[]gobot.Connection{sparkCore},
		[]gobot.Device{led},
		work,
	)

	gbot.AddRobot(robot)

	gbot.Start()
}