This week’s assignment was to design and program a smart device that performs a certain function.
I chose to make smart Toll Tax System because I watched a video about it, I liked the idea, and decided to simulate it
Arduino IDE to upload the code to the Arduino Uno
Autodesk Tinkercad Circuits to Simulate the electric circuits and Code Block
Electric Components:
breadboard, jumpers to connect the component
2 ultrasonic Sensor &servo motor & Buzzer
Arduino Uno to read the input signals from the 2 ultrasonic Sensor & accordingly, control the rotation of servo motor and sound from buzzer
other Components:
cardboard
plastic
glue
Inputs
Ultrasonic sensor: sense distance of an object
Action
The servo motor rotates 90 degree angle for 3 seconds and then get back to start point .
Buzzer produces sound
Brain
An Arduino UNO board will be used take inputs and generate actions
First I searched on Google the wiring diagram click
Then started following the diagram on my own circuit
Schematic View
Component List
Code Screens
Identify trigger pin 1 (3) and echo pin1 (2)
Identify the servo as "Servo lock" and its initial position is the angle (90).
Identify trigger pin 2 (4 and echo pin2 (5)
Set the output pins(7) for buzzer and pin (9) for servo.
I used If Function
The first if function:
If: Read ultrasonic distance less than 20cm --> then the buzzer pins read High (produces sound ).
The other if function:
If: Read ultrasonic distance less than 20cm -->Then the servo angle goes (0) --> pull the gate and open it.
If:other than Read ultrasonic distance less than 20cm--> Then the servo angle goes (90) --> closes it back
Then uploaded the code to the Arduino IDE.
Uploading text code on Arduino
The Arduino board was connected to the laptop and the right port was chosen "Tools ==> Port ==> COM5 Arduino UNO"
Then, It was uploaded successfully
Building the physical circuit
The breadboard, Jumpers, ultrasonic Sensor , Servo Motor, buzzer & ِArduino UNO were taken from the electronic kit
The circuit was built physically (exactly as it was designed on Tinkercad) using the hardware components and wires
breadboard was connected to the 5V for Arduino (5V as some were needed for servo motor and ultrasonic and buzzer sensor ) represented by red wire
Trig pin of first ultrasonic sensor was connected to pin 3
Echo pin of first ultrasonic sensor was connected to pin 2
Trig pin of second ultrasonic sensor was connected to pin 4
Echo pin of second ultrasonic sensor was connected to pin 5
Pin for buzzer was connected to pin 7
Pin for servo motor was connected to pin 9
I struggled alot with coding of the ultraosnic sensor
I seached alot all of the over google for a suitable code but most of them didnt work till i found a code and i started adding and twinking it to my understanding
one of the mistakes that i did was not connecting the echo pin and trigger pin to the correct pin done in the code , so it took me a while to figure this mistake out
another one was with the buzzer , i switched the positions of the +ve and -ve wiring.
also the mounting without the use of glue took a lot of imagination at the end i used something similar to nail
text coding is the skill i acquired this week , so hard but i think it will be so beneficial on the long run