summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..e874f7c
--- /dev/null
+++ b/main.go
@@ -0,0 +1,41 @@
+package main
+
+import (
+ "fmt"
+
+ "gobot.io/x/gobot"
+ "gobot.io/x/gobot/drivers/gpio"
+ "gobot.io/x/gobot/platforms/raspi"
+)
+
+func main() {
+ r := raspi.NewAdaptor()
+ led1 := gpio.NewLedDriver(r, "29")
+ //led2 := gpio.NewLedDriver(r, "31")
+ //led3 := gpio.NewLedDriver(r, "33")
+ led4 := gpio.NewLedDriver(r, "35")
+
+ motion := gpio.NewPIRMotionDriver(r, "16")
+
+ work := func() {
+ motion.On(gpio.MotionDetected, func(data interface{}) {
+ fmt.Println(gpio.MotionDetected)
+ led1.On()
+ led4.On()
+ })
+
+ motion.On(gpio.MotionStopped, func(data interface{}) {
+ fmt.Println(gpio.MotionStopped)
+ led1.Off()
+ led4.Off()
+ })
+ }
+
+ robot := gobot.NewRobot("Nistkasten",
+ []gobot.Connection{r},
+ []gobot.Device{motion, led1, led4},
+ work,
+ )
+
+ robot.Start()
+}