I want to complete this small robot which is used to sense if there is an object near by a specific distance to be also print a sentence in a screen.
I made this project to protect my laptop from the children in my house. As when they will be near by my laptop the buzzer turns on and the LCD print "Object detected ".
Circuit design software
OUR LOYAL FRIEND
Google: To search for whatever i need to know to complete the assignment.
Tinkercad: The main tool in this assignment, As i made the electrical circuit in it to make sure from the idea and from its validity
Cardboard: for the device enclosure.
Cutter: to cut the cardboard to make the wanted prototype parts
Hot glue gun : to assemble the parts together and get out with the device enclosure
Breadboard:
5 Volt Adapter:
Servo-Motor :
Buzzer:
Ultrasonic sensor:
wires:
LCD:
Slide switch
The action components that you used:
Servo motor
Ultrasonic sensor
Buzzer
LCD
Slide switch
Voltage source
5 Volt adapter : to provide the voltage for Servo motor ,Buzzer and the Ultrasonic sensor
This screenshot represent the project connection
1-Servo motor connected in pin 5
2- Ultrasonic sensor the trigger in pin 6 and echo in pin 7
3- Buzzer connected to pin 4
4- LCD connected SDA to pin A4 and SCL to pin A5
5- Slide switch connected to pin 8
TinkerCAD simulation
Text Code
1- include libraries :
servo.h for servo motor
Wire.h and LiquidCrystal_I2C.h for LCD
2- variable identifications. : For servo , LCD and ultrasonic.
3-Void setup: it has the dentification of the pin modes between input and output.
Text Code
4- Void loop:
Start the loop with for function to make the servo rotate from 0 degree to 180 and back
Then if function the distance is less than 10 cm the buzzer in pin 4 will be high and make a sound and the LCD print "Object detected" .
The sound of the buzzer will turn off when the slide switch is HIGH
else the buzzer will be low and the LCD print "No object detected".
Project final
I test all components to make sure that all of them work.(servo alone - ultrasonic sensor +Buzzer+ LCD)
I connect all the components together
Making sure from the connection with the Arduino and breadboard
Take the text code from tinkerCAD to Arduino IDE to compile it and upload it to the Arduino UNO
Connecting them to the 5 voltage adaptor
This video show the progress of the project
The servo motor start rotate with the ultrasonic above it
The ultrasonic sensor detect if there is an object 10 cm away from it or not
while put my hand in front or while it see the nearby wires while rotating the buzzer turns on and the LCD print "Object detected" .
When i move the slide the buzzer is turn off and still the LCD print "Object detected" .
other wise the buzzer will be low and the LCD print "No object detected".
I face a problem will connecting the LCD code and wiring because of it have many libraries that are used in the IDE
I saw many tutorials and projects ,i find out the most common one is <Wire.h> <LiquidCrystal_I2C.h>
As example for the library that doesn't work with be is
#include <Adafruit_LiquidCrystal.h> i see it in TinkerCad
GOOD LIBRARY
DOESN'T WORK LIBRARY
Another problem it was with the slide switch while the connecting process. Because of its pins the female male wires doesn't work good so i have to solder it with as shown in the following picture.
The most important 2 things i learned in this week:
be care about the wiring
test each component individually
choose the suitable library for the component that i have