forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
joule_leds.go
49 lines (40 loc) · 897 Bytes
/
joule_leds.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"time"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/joule"
)
func main() {
gbot := gobot.NewGobot()
e := joule.NewJouleAdaptor("joule")
led0 := gpio.NewLedDriver(e, "led", "100")
led1 := gpio.NewLedDriver(e, "led", "101")
led2 := gpio.NewLedDriver(e, "led", "102")
led3 := gpio.NewLedDriver(e, "led", "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(2*time.Second, func() {
led2.Toggle()
})
gobot.Every(3*time.Second, func() {
led3.Toggle()
})
}
robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{e},
[]gobot.Device{led0, led1, led2, led3},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}