This week's videos inspired me to do this small project this project is a warning that there is movement or a person at a certain distance
how the circuit works :
When there is any object at a distance of less than 10 cm from the sensor, the Buzzer emits a sound and the led lights up, but if the distance between the body and the sensor is more than 10 cm centimeter, the RGB lights only and the Buzzer and the led don't work.
Arduino IDE
Used to compile the code written in the programming sketches and upload it directly to the Arduino Board.
List of Components Used:
Breadboard.
Arduino Uno.
led.
4-Resistor 330 ohms.
RGB.
Ultrasonic sensor.
Buzzer.
Cable.
Wires.
The circuit diagram
The code is two blocks , first block control the buzzer and led via read the distance through triiger pin and echo pin anf if the distance less than or equal 10 cm will turn the buzzer and led , else the buzzer and led will be off .
the second block control the RGB led via ead the distance through triiger pin and echo pin anf if the distance more than 10 cm the RGB will turn , else the RGB will be off.
Simulation on Tinker CAD
finally,I converted the code blocks made in Tinkercad to text code, then this code is copied and pasted in a new sketch in the Arduino IDE.
I started to make the connections on the real breadboard according to the design on Tinker CAD.
The trigger pin is connected to pin 9 and the echo pin is connected to pin 8,
The buzzer is connected to pin 4 and the led is connected to pin 7,
The Ris GB is connected to pins 3,5 and 6,
Finally the power of the circuit from the Arduino through (5 V) pin and powered the Arduino through the cable.
I used an Avometer to know the value of the resistances.
Had some problems connecting in the ultrasonic sensor, but I went back and checked the previous week's lectures to refresh and remember how to do it correctly.