Project page: http://antontsv.github.io/r2d2
- Raspberry PI Model B+
- Edimax WiFi
- 5V blinking red LED
- DC 5V Power supply Micro USB, 2A
- HC-SR50 PIR sensor
- HC-SR04 ultrasonic sensor (with 1KΩ, or better have voltage divider)
- X-mini speaker
Image is taken from this blog post: Raspberry Pi B+ GPIO Header Details And Pinout
Install necessary packages and install as daemon/startup process:
sudo ./install
# Showcase help & options
./sensor_showcase.py --help
# All demos (you will have 30 seconds for each to see and test)
sudo ./sensor_showcase.py --all
Usually LEDs are ~2.5V and will require resistor in a circuit as Raspberry PI gives only 3.3V or 5V. So I was happy to find this little one at local radioshack, which also happens to blink automatically.
So your's might just give constant light, and most likely require an extra resistor (or you can watch your LED to burn in front of you). Also keep in mind connection polarity: usually longer leg is connected to power (red wire) and shorter leg is connected to the ground
Connection pins for LED:
- Power: #12 aka "GPIO18"
- Ground: #9
# Runs for 30 seconds (5 seconds on / 3 seconds off cycles)
sudo ./sensor_showcase.py --led
Passive infrared (PIR) sensor with 2 controls on top:
- Left: sensitivity
- Right: time delay (sensor outputs a signal for a pediof of time after initial motion is detected)
Also for R2D2 I plan to narrow this sensor's field of vision by painting most of the fresnel lens of the sides (robot needs a black eye)
Connection pins for PIR sensor:
- VCC: #4
- OUT: #26 aka "GPIO7"
- GND: #39
# Runs for 30 seconds (prints message if motion is detected)
sudo ./sensor_showcase.py --motion
Simple: emit sound pulse, and sense the echo. That it all boils down to simple equation as we know speed of sound in the air.
Also I hope you are not going to submerge the sensor in water or use it the moist environment.
Important: needs voltage divider, or some kind of resistor (I used 1kΩ 0.5W) to protect raspberry pi pin from echo's 5V output. See that purple wire on the pictures.
Connection pins for ultrasonic sensor:
- Gnd: #34
- Echo: #13 aka "GPIO27" (+ 1KΩ resistor)
- Trig: #11 aka "GPIO17"
- Vcc: #2
# Runs for 30 seconds (prints average distance over period of 3 seconds)
sudo ./sensor_showcase.py --distance