PIR Motion Sensor
Simple interface that makes it possible to detect motion by using a proximity motion sensor.
API ReferenceHow To Connect
Install the package with: go get gobot.io/x/gobot
How To Use
This example detects motion, then turns on and off a LED
package main import ( "fmt" "gobot.io/x/gobot" "gobot.io/x/gobot/drivers/gpio" "gobot.io/x/gobot/platforms/firmata" ) func main() { firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0") sensor := gpio.NewPIRMotionDriver(firmataAdaptor, "5") led := gpio.NewLedDriver(firmataAdaptor, "13") work := func() { sensor.On(gpio.MotionDetected, func(data interface{}) { fmt.Println(gpio.MotionDetected) led.On() }) sensor.On(gpio.MotionStopped, func(data interface{}) { fmt.Println(gpio.MotionStopped) led.Off() }) } robot := gobot.NewRobot("motionBot", []gobot.Connection{firmataAdaptor}, []gobot.Device{sensor, led}, work, ) robot.Start() }