Categories: Beginner
Hello,
I would be lying to you if I told you I was using this software to test if I was sleeping and moving around while sleeping. But…
This PIR Sensor could be used for this type of testing, e.g. "Did I move while sleeping between a specific interval during the night?"
…
import Adafruit_BBIO.GPIO as GPIO
import time
GPIO.setup("P8_12", GPIO.OUT)
PIR_PIN = "P8_8"
GPIO.setup(PIR_PIN, GPIO.IN)
GPIO.add_event_detect(PIR_PIN, GPIO.RISING)
while True:
if GPIO.event_detected("P8_8"):
GPIO.output("P8_12", GPIO.HIGH)
print("Motion Detected!")
time.sleep(10)
else:
GPIO.output("P8_12", GPIO.LOW)
print("You are not moving while sleeping!")
time.sleep(10)
This is free software that I use while researching ideas and using an if/else statement.
…
First…assemble the PIR Sensor and the LED.
On your PIR Sensor:
- You have three pins if purchased from Adafruit at
https://www.adafruit.com/product/189. - One is GND, another is OUT, and the last one is 5v. These three pins are situated like this to the BBB.
- PIR GND to BBB GND
- PIR OUT to BBB P8_08
- PIR 5v to BBB vdd_5v (this vdd_5v pin needs the 2A power adapter to be plugged in while testing this software)
Now…we need to set up our LED.
- BBB GPIO (P8_12) to Anode of the LED
- Cathode of the LED to 1K ohm resistor to GND on the BBB
Sort of like this idea from Fritzing:
Second…try the source to attempt to make your LED light once the PIR Sensor has detected your movement.
…
If the PIR sensor is not detecting your movement, try to use the 2A adapter like this one:
https://www.sparkfun.com/products/15312
.
If you want, from what I have learned, you can also use sys_5v on pin P9_7 or P9_8. vdd_5v is P9_5 and P9_6.
Seth
Comments are not currently available for this post.