I searched about projects on google and I find a project using the humidity sensor, but I had a problem with it.
I heard some of my colleagues talking about it, and I was Curious about how can I make it, so I start to search about it and I find it simple and I can make it with my kit, so I decided to make it.
I used the Ultrasonic sensor, LED's, buzzer and switch to on\ off the project.
Tinker CAD
It is a very helpful software, helps to do mistakes without real damage.
Slide switch to open and close the project.
Ultra sonic to give the leds input ,so it will light at specific distance.
buzzer, make different sounds at different distances.
Jumpers to connect the components
leds take the output from ultrasonic
I started wiring
using Arduino, breadboard, 3 LEDs, buzzer, and slide switch
The connections
-putting
the buzzer at the breadboard connect its Gun to ground of Arduino at the
breadboard, and the power to 3 pin on Arduino to take the reading of Ultrasonic.
-I connected the three LEDs to the Gun of
Arduino and the power to 9,10,11 pins at Arduino respectively.
- Ultrasonic connected to Gun and 5 V power of
Arduino, Trigger and echo to 5,6 pins on Arduino.
-Side switch connected it to power and ground
of Arduino at the breadboard and the I/O to 2 pin.
I started to write the code
Before any thing I declared the variable.
Then I begin the Serial and declare
every pin if it input or out put.
Finally I started to write the code at void
loop which include the main code (which will be repeated )
I
start with If condition which will include the most of code, will start when
the side switch will be high, and inside this if condition there is
another three if conditions, condition for every LED
First
condition for Yellow LED which will light when the distance between 20 and 15,
and the buzzer will make specific sound.
Second
condition for Green LED which will light when the distance between 15 and 10,
and the buzzer will make another sound which mean the car get closer.
third
condition for Red LED which will light when the distance between 10 and 0, and
the buzzer will make sound which mean there is something bad will gonna happen.
I was confused about the second input, so I asked Eyad and Eman and both of them recommended me to use the switch button.
In the beginning, I use the big difference between distances and used large distances like 50, Ultrasonic can not read it and as a result, can not take any action to light the labs or make a sound from the buzzer.
Using more than one input and output, give me experience to make the final project.
Title of Media
Title of Media