my idea for this week is an alarm device.
I used tinkercad as a software to draw the circuit, programe it with code blocks then simulate it.
I also used some components from the electronic kit:
1- Breadboard to connect the component with each others without using extra wires.
2-Jumpers to connect components to bread board and arduino.
3- ultra sonic sensor.
4-buzzer.
5- arduino uno.
Firstly, I collect the components that I'll use which were ( breadboard,Jumpers,buzzer, ultra sonic sensor and arduino uno.
then, I put the sensor in the breadboard and connect it with arduino as following:
1- vcc with 5 volt.
2- GND with arduino GND.
3- trig with pin .
4-echo with pin 10.
and then, I connect the positive of buzzer with pin 2 and negative one with GND.
Finally, I connect the arduino to laptop.
After I made the circuit, I start to write the code using code blocks.
I chose "read ultrasonic distance sensor on trigger pin 9 and echo pin" from input blocks.
then, " comparison <10".
after that, I chose "If and else" from control blocks.
How I play it?
I copied the code and pasted it in arduino then uploaded it.
if the distance between the object and ultrasonic sensor is less than or equal to 10 cm, the buzzer will produce a buzz. if the distance bigger it will not work.
I asked Marium many times actually
it was my first time to use the ultrasonic sensor and I liked it when it detects the distance :"D
Tinkercad code blocks .
the distance was more than 10 cm so, the buzzer didn't buzz.
the distance was less than 10 cm, so it buzzed.
the code on arduino.