35 lines
580 B
Go
35 lines
580 B
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
"github.com/hybridgroup/gobot/api"
|
|
"github.com/hybridgroup/gobot/drivers/gpio"
|
|
"github.com/hybridgroup/gobot/platforms/particle"
|
|
)
|
|
|
|
func main() {
|
|
gbot := gobot.NewGobot()
|
|
api.NewAPI(gbot).Start()
|
|
|
|
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,
|
|
)
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
gbot.Start()
|
|
}
|