Update spark examples
This commit is contained in:
parent
4449d909e4
commit
6e0126698e
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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{}) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue