50 lines
855 B
Go
50 lines
855 B
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
"github.com/hybridgroup/gobot/drivers/gpio"
|
|
"github.com/hybridgroup/gobot/platforms/intel-iot/joule"
|
|
)
|
|
|
|
func main() {
|
|
gbot := gobot.NewGobot()
|
|
|
|
e := joule.NewAdaptor()
|
|
led0 := gpio.NewLedDriver(e, "100")
|
|
led1 := gpio.NewLedDriver(e, "101")
|
|
led2 := gpio.NewLedDriver(e, "102")
|
|
led3 := gpio.NewLedDriver(e, "103")
|
|
|
|
work := func() {
|
|
led0.Off()
|
|
led1.Off()
|
|
led2.Off()
|
|
led3.Off()
|
|
|
|
gobot.Every(1*time.Second, func() {
|
|
led0.Toggle()
|
|
})
|
|
gobot.Every(2*time.Second, func() {
|
|
led1.Toggle()
|
|
})
|
|
gobot.Every(4*time.Second, func() {
|
|
led2.Toggle()
|
|
})
|
|
gobot.Every(8*time.Second, func() {
|
|
led3.Toggle()
|
|
})
|
|
}
|
|
|
|
robot := gobot.NewRobot("blinkBot",
|
|
[]gobot.Connection{e},
|
|
[]gobot.Device{led0, led1, led2, led3},
|
|
work,
|
|
)
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
gbot.Start()
|
|
}
|