RpiGarageDoorDistanceSensor

by Ishreet123 in Circuits > Raspberry Pi

1619 Views, 11 Favorites, 0 Comments

RpiGarageDoorDistanceSensor

0268E335-FA4B-44A3-8B89-5D027602FAF9.jpeg

This tutorial will give you a step by step process on how to create a garage door distance sensor for when a car is entering a garage, with the raspberry pi.

Gather Your Materials

560 ohm resisitor.jpg
wires.jpg
micro servo.jpg
leds.jpg
button.jpg
breadboard.jpg
330 0hm resistor.jpg
distance sensor.jpg
Raspberry-Pi-3-1-1619x1080.jpg

Start off by collecting the following materials:

1. Raspberry Pi

2. Breadboard with t-cobbler (attached to Rpi)

3. Distance sensor

4. Jumper wires

5. Green, red, and yellow LEDs (one of each)

6. Two 560 ohm resistors

7. Three 330 ohm resistors

8. One button

9. Micro Servo

Wiring the Distance Sensor

7371954C-A0D8-4A80-BEEC-28A6086A02DB.jpeg

Stick the Distance Sensor into the breadboard vertically. Then using jumper wires, put the VCC pin into the 5V and the GND pin into the ground rail of the breadboard (make sure that your GND and power rail is connected to the GND and 5V of the rpi).

Then using two 560 ohm resistors, connect one of the resistors to the echo pin going vertically. Using a jumper wire, connect one side to GPIO 24 whereas the other side connects to the resistor. Then using the second resistor, connect one leg to the first resistor and the GPIO pin, and the other leg to the ground rail (refer to picture above).

Setting Up the LEDs and the Button

AB729872-4442-47E8-A654-25CA73343855.jpeg

The LEDs will indicate how close and how far you are from the distance sensor

Setup your three coloured LEDs on the breadboard going vertically. Using the 330 ohm resistor, connect each LED's short leg to one side of the resistor which then connects to the ground rail. Connect the other leg to a GPIO pin using jumper wires.

GPIO pins For Each LED:

Red: GPIO 26

Yellow: GPIO 27

Green: GPIO 4

The button will give command to the servo to move a certain direction which will then open and close the garage door.

For the button connect the bottom leg to the ground rail and the top leg to GPIO 13.

(refer to the picture above)

Connecting the Micro Servo

B335803A-9107-4C1A-85A6-CF4DCB8FE8C9.jpeg

The servo would play the role to open and close the garage door.

Using jumper wires (or female to female wires), connect the orange wire to GPIO 18, the red wire to 5V and the black wire to the GND pin.

(Tape the servo to the breadboard so when the servo moves the "garage door" it will stay upright like shown in the picture above)

The Code

Here is the download to the code.

Customize

garage door.jpg

Now you can make this project look like a car entering a garage door by using different materials and your creativeness!