During my recent trips, I noticed how car security gates are used at parking lots and residential areas to regulate entry and exit. I was inspired by how these gates combine mechanical design, sensors, and access control systems to improve both safety and convenience.
Software
Materials
Electronics
Design the circuit using Tinker Cad
I created a new circuit sketch on Tinker Cad.
I dragged the following components:
IR sensor
Servo Motor
Breadboard
Arduino UNO
Wiring the circuit
IR Sensor [INPUT]:
VCC (Red wire) → Breadboard positive rail → Arduino 5V
GND (Black wire) → Breadboard ground rail → Arduino GND
Signal (Green wire) → Digital pin 6 on Arduino
Servo Motor [OUTPUT]:
GND (Black wire) → Breadboard ground rail → Arduino GND
VCC (Red wire ) → Breadboard positive rail → Arduino 5V
Signal (Orange wire) → Digital pin 3 on Arduino
Breadboard Power Rails:
Arduino 5V connected to red (positive) rail on breadboard
Arduino GND connected to black (negative) rail on breadboard
Servo motor and IR sensor are powered via the breadboard rails
Programming Arduino using Code Blocks in TinkerCad
I used Code Blocks to set the input and the output as shown in the image below.
I tested the logic of the code through the serial monitor. When the object is out of the range of the IR sensor, the serial monitor prints "No object - Servo at 0 degrees"
And when the object is within the range of the IR sensor, the serial monitor prints "Object detected - Servo at 90 degrees"
Simulation Video of the circuit
I uploaded the code to the Arduino UNO board through the USB cable. Then, I wired the IR and Servo and ran a test to make sure that everything is working before putting them in place.
Testing the code
The final product!
At first, I was unsure whether to use an ultrasonic sensor or an IR sensor. Some online resources suggested ultrasonic sensors because they are accurate for measuring distance, but others noted that IR sensors have a faster response time and are simpler to integrate. Since my project only needed to detect the presence of a car rather than measure its distance, I chose the IR sensor. The quick response made it more suitable for opening and closing the gate without delay.
At the beginning, I got stuck because the servo motor kept opening and closing too fast. I turned to online resources, and I realized that I needed to add a delay function in my code to control the timing.
I can use this week’s skills in my digital ruler final project. At first, I planned to use a rotary encoder, but Menna Asker suggested an IR sensor, which actually aligned with my initial idea when I inspected an old laser mouse and discovered it uses a similar mechanism. This week’s assignment gave me good hands-on training with the IR sensor, which will help me apply it more effectively in my final project.
The coolest thing I learned this week was the mechanism of the optical mouse. I discovered that it doesn’t rely on wheels or mechanical parts, but instead uses two IR sensors along with a small LED or laser to track movement across a surface. The mouse constantly shines light on the surface and the sensors detect the reflected patterns. By comparing the signals from the first and second sensors, the mouse can determine whether it is moving up, down, left, or right. This principle of analyzing the shift between two signals (called quadrature detection) is both simple and powerful. I will never forget how such a tiny, everyday device uses this elegant system to translate small physical movements into precise digital signals.
Title of Media