hybridgroup.gobot/examples/particle_blink.go

29 lines
433 B
Go

package main
import (
"time"
"gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/gpio"
"gobot.io/x/gobot/platforms/particle"
)
func main() {
core := particle.NewAdaptor("device_id", "access_token")
led := gpio.NewLedDriver(core, "D7")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("spark",
[]gobot.Connection{core},
[]gobot.Device{led},
work,
)
robot.Start()
}