At this project I am inspired of the idea of car parking sensor or any other proximity alarm system which detects nearby objects and fires an alarm of light & sound.
Software used:
TinkerCad to design & simulate circuit.
Arduino IDE to upload the code to the Arduino
Components:
Arduino Uno
Ultrasonic sensor
LED
Buzzer
330 ohm resistance
Jumpers
Breadboard
Input: Ultrasonic sensor
Output: LED & Buzzer
In this circuit the ultrasonic is the input (Trigger on Pin no. 11 , Echo on pin no. 10) , as it controls both buzzer (Pin no. 9) and LED (Pin no. 8).
When the sensor detects and object at a distance equal to or less than 35 cm, it orders the two output components to work.
This code detects any body in the range of 35 cm to trigger the alarm (LED+Buzzer)
It depends on IF condition: if the distance of the body detected is less than or equal 35 cm, the signal on both buzzer and LED is high for one second, then low for one second making them blinking like alarm.
If the distance detected by the ultrasonic is greater than 35 cm, then the signal on LED & buzzer is low, so they don't work.
I started to mount each component to the bread board. I connected a common ground from Arduino to breadboard, And connected the ground of the LED, buzzer & sensor to it.
other components are connected to the Arduino using the same color code as used on TinkerCad.
Code is downloaded from TinkerCad by clicking on download
After downloading the code, I opened the .ino file in Arduino IDE and the clicked on upload after making sure that selected port is Arduino board.
You can download the code from here
I made a mistake in a connection for the ground of the LED, after revising the circuit I figured it out and corrected it, and everything went fine after that.
Our Instructor (Menna) gave us a valuable advice to organize wire connections following a color code, this helped much in visualizing the circuit and also made it easier when making it using components following the same color code.