Update spark examples

This commit is contained in:
Adrian Zankich 2014-06-08 18:37:14 -07:00
parent 4449d909e4
commit 6e0126698e
4 changed files with 8 additions and 10 deletions

View File

@ -10,11 +10,10 @@ import (
func main() {
master := gobot.NewGobot()
api.Api(master).Start()
api.NewApi(master).Start()
sparkCore := spark.NewSparkCoreAdaptor("spark", "device_id", "access_token")
led := gpio.NewLed(sparkCore, "led", "D7")
led := gpio.NewLedDriver(sparkCore, "led", "D7")
work := func() {
gobot.Every(1*time.Second, func() {

View File

@ -11,7 +11,7 @@ func main() {
master := gobot.NewGobot()
sparkCore := spark.NewSparkCoreAdaptor("spark", "device_id", "access_token")
led := gpio.NewLed(sparkCore, "led", "D7")
led := gpio.NewLedDriver(sparkCore, "led", "D7")
work := func() {
gobot.Every(1*time.Second, func() {

View File

@ -4,15 +4,14 @@ 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.NewLed(sparkCore, "led", "D7")
button := gpio.NewButton(sparkCore, "button", "D5")
led := gpio.NewLedDriver(sparkCore, "led", "D7")
button := gpio.NewButtonDriver(sparkCore, "button", "D5")
work := func() {
gobot.On(button.Events["push"], func(data interface{}) {

View File

@ -11,13 +11,13 @@ func main() {
master := gobot.NewGobot()
sparkCore := spark.NewSparkCoreAdaptor("spark", "device_id", "access_token")
led := gpio.NewLed(sparkCore, "led", "A1")
led := gpio.NewLedDriver(sparkCore, "led", "A1")
work := func() {
brightness := uint8(0)
fade_amount := uint8(15)
fade_amount := uint8(25)
gobot.Every(0.5*time.Second, func() {
gobot.Every(500*time.Millisecond, func() {
led.Brightness(brightness)
brightness = brightness + fade_amount
if brightness == 0 || brightness == 255 {