2016-08-26 00:10:52 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/drivers/gpio"
|
|
|
|
"gobot.io/x/gobot/platforms/intel-iot/joule"
|
2016-08-26 00:10:52 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-03 22:58:43 +08:00
|
|
|
e := joule.NewAdaptor()
|
|
|
|
led0 := gpio.NewLedDriver(e, "100")
|
|
|
|
led1 := gpio.NewLedDriver(e, "101")
|
|
|
|
led2 := gpio.NewLedDriver(e, "102")
|
|
|
|
led3 := gpio.NewLedDriver(e, "103")
|
2016-08-26 00:10:52 +08:00
|
|
|
|
|
|
|
work := func() {
|
|
|
|
led0.Off()
|
|
|
|
led1.Off()
|
|
|
|
led2.Off()
|
|
|
|
led3.Off()
|
2016-08-26 03:29:19 +08:00
|
|
|
|
2016-08-26 00:10:52 +08:00
|
|
|
gobot.Every(1*time.Second, func() {
|
|
|
|
led0.Toggle()
|
|
|
|
})
|
|
|
|
gobot.Every(2*time.Second, func() {
|
|
|
|
led1.Toggle()
|
|
|
|
})
|
2016-10-03 22:58:43 +08:00
|
|
|
gobot.Every(4*time.Second, func() {
|
2016-08-26 00:10:52 +08:00
|
|
|
led2.Toggle()
|
|
|
|
})
|
2016-10-03 22:58:43 +08:00
|
|
|
gobot.Every(8*time.Second, func() {
|
2016-08-26 00:10:52 +08:00
|
|
|
led3.Toggle()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("blinkBot",
|
|
|
|
[]gobot.Connection{e},
|
|
|
|
[]gobot.Device{led0, led1, led2, led3},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2016-10-19 03:08:25 +08:00
|
|
|
robot.Start()
|
2016-08-26 00:10:52 +08:00
|
|
|
}
|