Car Gate

by 762362 in Circuits > Arduino

20 Views, 1 Favorites, 0 Comments

Car Gate

Screenshot 2025-06-16 180431.png

Original Credits and Idea go to The Neo Studios - https://www.youtube.com/watch?v=O7yoa-hwnkI

This project is a slightly modified version of The Neo Studio's car gate circuit.

Supplies

Screenshot 2025-06-16 181646.png

330ohm Resistors(2)

LED(2)

Ultrasonic Distance Sensor(1)

Servo Motor(1)

Arduino Uno(1)

Wires

Breadboard(1)

Assembling the Circuit on Breadboard

Screenshot 2025-06-16 182040.png

Wire the components onto the Arduino and Breadboard.

  1. LEDS - 330ohm resistors connected to cathode and ground, pin 10 and 11 are connected to anode.
  2. Distance Sensor - trig connected to pin 6 and echo connected to pin 7. Also connected to power and ground on the Breadboard.
  3. Servo Motor - Connect to power and ground on the breadboard. After connect the signal to pin 9 on Arduino.

Code

Screenshot 2025-06-16 183420.png

Create the variables you will use within your code.

Distance Sensor Funciton

Screenshot 2025-06-16 183507.png

This function will allow you to use the distance sensor easier within the loop of your code.

Setup

Screenshot 2025-06-16 183611.png

Within the setup you pinMode the LEDS and the servo motor.

Loop of Code

Screenshot 2025-06-16 183728.png

Within this loop you make the equation "cm = 0.01723 * readUltrasonicDistance(6, 7);" to allow the unit to be in centimeters.

Afterwards you make the if loop where the distance sensor will only activate the servomotor once the distance is less than 5 cm.

The two For loops after that which include pos(the position of the servo motor) will adjust accordingly to make the gate move up and down. As this happens the two LEDS will also turn on and off accordingly when the gate opens and closes.

Final Product

This is a video of the final product of this project working. Although it doesnt look too good it still works.

Downloads