Car Parking Assistance Systems
For this week’s assignment:
I built a circuit using an Arduino UNO, an LED, a buzzer, and an ultrasonic sensor.
The ultrasonic sensor works as the input component, while the LED and buzzer are the output action components.
Why I Care About This Idea:
I’m really excited to work with the ultrasonic sensor because it has so much to learn and explore.
It uses a trigger pin to send signals and an echo pin to receive them, allowing it to sense the distance of nearby objects.
I find it interesting to program how the sensor detects objects within a specific range, then activates the LED and buzzer as alerts.
Inspiration
I was inspired by real-life uses of ultrasonic sensors, such as in car parking assistance systems, obstacle-avoiding robots.
These applications show how combining distance measurement with visual and sound feedback makes a system more intelligent and useful.
Software
I used Tinkercad to simulate the circuit.
This helped me make sure it works correctly, without errors or damage to components 🙂.
I used Arduino IDE to write and upload the code directly to the Arduino UNO .
Materials (for the circuit)
Ultrasonic Sensor
Arduino UNO - Arduino Cable
LED
Resistor 220Ω
Buzzer
Breadboard
Male-Male Jumper Wires
First: To Simulate the Circuit
1- I opened the Tinker cad website in the browser.
2- logged in with my email.
3- Then I started creating a new circuit.
Second: Creating The Circuit
1- I searched for the components I needed:
a- Breadboard Small b- Arduino UNO r3 c- LED d- One resistor (I made sure it was 220 Ω). e- Ultrasonic Distance Sensor (with 4 Pins) f- Buzzer
2- I placed the LED on the breadboard.
3- Since an LED only requires around 2V to light up, but the Arduino’s digital pins provide 5V, connecting it directly could burn it out.
4- To prevent this, I added a resistor in series with the LED (connected to its cathode/ground side).
(The resistor limits the current, ensuring that the LED receives only the amount of current it needs to operate safely.)
5- I connected the other side of the resistor to the ground rail on the breadboard using a black wire.
6- Then, using a red jumper wire I connected the positive leg of the LED to pin D9 on the Arduino, which serves as the signal/control pin for the LED.
7- For the buzzer, I connected the negative pin to the ground rail on the breadboard.
8- Then, I connected the positive leg of the buzzer to pin D8 on the Arduino using a purple wire, which serves as the signal/control pin for the buzzer
9- To supply power to the circuit, I used the 5V pin on the Arduino UNO by connecting it to the VCC pin (power pin) of the ultrasonic sensor with a red jumper wire.
10- For the input of the ultrasonic sensor (The Trigger pin), I connected it to pin D4 on the Arduino using an orange wire.
11- Then, I connected the GND pin of the ultrasonic sensor to the ground rail on the breadboard using a black jumper.
12- For the output of the ultrasonic sensor (The Echo pin), I connected it to pin D2 on the Arduino using a green jumper wire.
Third: Coding
A. Setting the Input
1- I started the code by defining the input for the ultrasonic sensor.
2- The sensor receives signals from objects within a specific distance. To measure this, I used the block:
read ultrasonic distance sensor trigger pin (4) echo pin (2) in (cm)
3- I placed this inside a math block to store the value of the distance, and I set the threshold distance to 40 cm.
B. Setting the Output with Conditions
4- Next, I added an if/else condition block to control the outputs (LED and buzzer) based on the measured distance.
5- I used the distance condition block in the condition area of the if/else statement.
C- LED Output:
6- I wanted the LED to fade in steps when an object is detected. For this, I used the block:
set pin () to ()
3 Times
Pin 9 → 0 (off)
Pin 9 → 127 (half brightness)
Pin 9 → 255 (full brightness)
7- Between each brightness step, I added a wait block (1 second) to create a fading effect.
D- Buzzer Output:
8- For the buzzer, I used the block:
set pin () to (High/Low)
9- set pin (8) to High → the buzzer turns ON when the object is within 40 cm.
10- set pin (8) to Low → the buzzer turns OFF when the object is out of range.
E- Else Condition
11- If no object is detected within the set distance, both the LED and buzzer remain OFF.
Applying the Circuit in Real
To apply the circuit in real life, I followed the same steps I did in Tinkercad
1- I started by placing the LED on the breadboard.
2- Then, I connected the negative leg of the LED to a resistor.
3- Then, I connected the other side of the resistor to the ground rail on the breadboard using a Blue jumper.
4- I placed the buzzer on the left side of the breadboard.
5- I connected its negative pin to the ground rail on the breadboard using a black wire.
6- Then I connect its positive pin to pin D8 on the Arduino using a yellow wire.
7- I went back to the LED to connect its positive leg to the Arduino. I connected it to pin D9 on the Arduino using a green wire.
8- Then, I placed the ultrasonic sensor between the LED and the buzzer on the breadboard.
9- I connected the VCC pin of the sensor to the 5V pin on the Arduino using a green wire.
10- Then, I connected the Trigger pin to pin D4 on the Arduino with a purple wire.
11- Then I connected the Echo pin to pin D2 using a blue wire.
12- Finally, I connected the GND pin of the sensor to the ground rail on the breadboard with a purple wire.
(making sure that all grounds in the circuit are unified)
Uploading the Code to the Arduino
After completing the wiring and coding.
1- I used the Arduino IDE to upload the code to the Arduino UNO.
2- Once the code was uploaded successfully, the circuit started running in real life: the ultrasonic sensor measured the distance, and based on the input, the LED faded, and the buzzer turned on or off according to the programmed conditions.
Steps:
1- I first connected my Arduino UNO to my laptop using a USB cable.
2- Then, I opened the Arduino IDE and wrote my code.
3- After that, I went to Tools and made sure to select the correct board (Arduino UNO) and the right port for my device.
4- Before sending the code, I clicked on the Verify button to check for any errors.
5- Once it was verified, I clicked the Upload button to upload the code to the Arduino.
6- After a few seconds, the circuit work, the ultrasonic sensor started measuring distances, the LED began to fade as programmed, and the buzzer turned on and off depending on the object’s position.
7- To test the circuit, I used my tiny Sanfor toy 😁 and walked it behind the ultrasonic sensor.
Whenever Sanfor got close, the LED lit up and the buzzer beeped, as if the sensor was catching him in the act 😂
During this week, I learned how to code the ultrasonic sensor with the Arduino and how to control a servo motor to create the “waving hand” project. While working on these tasks, I asked for feedback from my peers and mentors to ensure that my wiring and code were correct
While working on this assignment, I faced some challenges that required me to pause and learn more before moving forward. One of the first difficulties was understanding how the ultrasonic sensor works, especially the roles of the Trigger and Echo pins. To overcome this, I researched online tutorials and documentation to better understand how the sensor sends and receives signals.
By working with the ultrasonic sensor, I learned how to handle input components that sense the environment and use their signals to control different outputs.
This experience taught me how to correctly wire sensors, unify grounds, and use the Arduino IDE to program the logic.
Also, Coding with condition blocks and controlling multiple outputs (LED and buzzer) gave me confidence in programming more complex interactions.
In my final project, I can apply these skills to:
1- Integrate sensors (not just ultrasonic, but other types as well).
2- Control different outputs like lights, sound, or motors based on sensor input.
3- Debug and solve wiring or coding issues more efficiently.
4- Build a system that responds intelligently to its surroundings.
Overall, this week gave me a foundation in combining sensors, outputs, and code, which are essential skills for creating my final smart project.
This week, I discovered how to program the ultrasonic sensor with Arduino and use it to detect objects, which was really exciting to try out. I also learned how to control a servo motor and make it move like a “waving hand.”
One of the most unforgettable moments was seeing the project actually respond and wave back🤗, it felt like turning imagination into reality.
Title of Media
Title of Media