Build and Program a smart circuit using an Arduino UNO which reads a signal from an input component to control an action component using Code Blocks
I get inspired from google images and videos.
When the distance between the ultrasonic sensor become less than 10cm , the buzzer will produce sound.
Software Tools:
Tinker CAD: to build the virtual circuit
Arduino IDE: to upload the code to the Arduino board
TinkerCad
Arduino
BreadBoard
Buzzer
Ultrasonic Senor
Wires
Arduino Uno
Electric Components:
Breadboard, wires to connect the component
1 Ultrasonic
Buzzer
open Tinker CAD and drag all needed components.
Unifying the ground by taking a black wire from( buzzer and ultrasonic sensor) then connect with the board then from the board to the GND in Arduino Uno.
connect +ve in breadboard with 5V in Arduino , then connect VCC in US-sensor with +ve in breadboard
Each Ultrasonic sensor has TRIG and ECHO pins which are connected with digital link.
then simulate
Tinker CAD coding
Open blocks in tinker cad and starting to write the code.
Picking an If then else condition from the control category.
Drag comparison from math
Drag the block of reading ultrasonic sensors at distance less than 10 cm.
Then drag (set pin 4 to high) ,else (set pin 4 to low)
1- Call function named readUltrasonicDisance
2- If the value less than 10 ; activate buzzer connected on pin4
Function named readUltrasonicDisance
is controlling triggerpin and call pulseIn function to read the distance
This video demonstrates the work that I did in tinkerCAD step by step
Hard ware implementation process
Check all wires and components are connected properly, to the board.
check the connection between Arduino Uno and the board by following Tinker Cad simulation.
connect the Arduino Uno with USB cable which connected to the lab.
Upload the code and test it
Arduino IDE
Compiling the system on tinker cad by clicking on simulation.
After working the system properly, copying the code as a text from tinker cad.
Open Arduino IDE and upload the code on it to start the actual trial of the system.
1- Call function named readUltrasonicDisance
2- If the value less than 20 ; activate buzzer connected on pin4
Function named readUltrasonicDisance
is controlling triggerpin and call pulseIn function to read the distance
Challenge:
The code worked perfectly on tinker CAD but actually there was a problem in connection of ultrasonic wire. So, I asked instructor Israa for help and she advised me to check connection. Hence, I checked it and I found that ttiggrr and echo pins were inverted.