This week we need to create a project which have two outputs and making the wiring on tinkercad then creating blocks to get the final code so i chose to use ultrasonic sensor with buzzer and servo motor to produce this function ( As if the distance more than 10 the buzzer will be on and vice versa .
The second when the distance is around 30 cm as if it more than 30 the survo will turn from 0 to 90 and also vice versa)
i was inspired by this video
(https://www.youtube.com/watch?v=HynLoCtUVtU)
The material i used is 1- tinkercad and arduino Uno as a software / Arduino _ jumpers _ ultrasonic sensor _ servo motor _ buzzer _ breadboard as electronic components.
And the ultrasonic sensor will be considered as input component and the motor and buzzer will be as action components.
I also used 5 V power supply.
Title of Media
wiring diagram ( we notice that we use ultrasonic sensr with four pins on tinkercad ( vcc with 5V of arduino - GND with arduino GND - echo at pin3 of arduino - trigger at pin2 of arduino ) and it needs 5 voltage of power supply / then we have servo motor which have 3 pins ( vcc + arduino 5v - Gnd + arduino GND - IN + pin 7 at arduino ) and also it needs 5v of power supply.
i started with designing circuit on tinker CAD and simulate it as shown in this short video
Then i started with coding which i made using blocks on tinkercad then get the text one
(My code depending on two if conditions ... First one when the distance is around 10 cm ... As if the distance less than 10 the buzzer will be on and vice versa .
The second when the distance is around 30 cm as if it more than 30 the servo will turn from 0 to 90 and also vice versa)
coding blocks ( we can find here that we define the ultrasonic sensor pins (tigger and echo pin on (3/2) and buzzer connected with pin 3 on arduino and by using if conditions block we ordered the buzzer to be on and the servo motor ( at 7 pin ) will be at 0 degree of rotation when the readings of ultrasonic is smaller than or equal 10 / then we code the second case between ultrasonic sensor and servo motor so if the readings of sensor become more than 30 the servo motor which (at pin 7 ) will rotate from zero to 90 degree and buzzer ( at pin 3 ) will be off)
The implementation ... First i started with designing the circuit on real .
Then i started with ultrasonic sensor to make it read the acquired distance and noticed the expected results,
Before this is uploaded the code on arduino .
then I tried to see the expected results.
Title of Media
Title of Media
This week my mind was free from idea so i asked my friend bassant to give me an idea and she helped me with this one.
and also i found this lovely project here
(https://create.arduino.cc/projecthub/theSTEMpedia/controlling-a-servo-motor-using-ultrasonic-sensor-d049bf)
This week challenge was that i don't know that servo motor has it's library to work with arduino so firstly the project wasn't work but when i asked my friend they told me about the library and then it worked
and this is the library of servo motor
// C++ code
#include <Servo.h>
Title of Media
i applied the circuit with the programing code and tested it , and now you can see it while it is working to give the acquired output
and you can find my testing video in this link
(https://drive.google.com/file/d/1GII5V5VXjUJoOKh_BTr1bUfDDkZakWU9/view?usp=sharing)
i think the best thing was the playing with tinker cad blocks and also
Title of Media
Title of Media