I choose to make smart trash can because I watched a video about it, I liked the idea, and decided to simulate it. I got inspired from this video
Software Tools:
Tinker CAD: to build the virtual circuit
Arduino IDE: to upload the code to the Arduino board
BreadBoard
BreadBoard
BreadBoard
Servo Motor
Ultrasonic Sensor
Wires
Arduino Uno
Electric Components:
Breadboard, wires to connect the component
1 servo motor: to open the can
1 Ultrasonic distance sensor: to detect the person coming near the can
slide swish : to control time of using can
LCD
Arduino Uno: to read the input signals from the ultrasonic sensors, and control the movement of the servo motor & LCD output messages
Others:
Cardboard - scissors- ruler - tape
Tinker cad circuit
Dragging all needed components.
connect all GND for all components (Ultrasonic sensor, servo motor LED and Button) to the bread board at the -ve common terminal using black wires.
connecting power from (Ultrasonic, servo and LED) to the common +ve on bread board with red wires.
connecting the second terminal of the button to Arduino on digital pin.
Ultrasonic has 2 opposite pins
Trig pin which is out put that produces Ultra sonic waves on pin 7 and the second one is In put pin (echo pin) that receives the US waves and return it to the Arduino on pin6
Servo motor on digital pin10.
circuit description:
-When there is any object at distance less than 10 from the ultrasonic and button is on the red led and servo motor should work.
A- Connection process
It is a simulation process to connections on tinker-cad.
Using the bread board and connect all GND wires from US-sensor, LED, Servo and switch to the common one in the board then to the ground of Arduino.
connecting all 5 volt pins from all components to the board then to the 5 V of Arduino.
connect signal pin of swish on pin 4
connecting servo to digital pin 10 in Arduino.
connecting trig & echo pins of US- sensor to the digital pins6 & 7.
connect LED on pin 8
B-Mounting Process
Using ruler and pencil to measure the needed parts to be cut to mount the components inside the enclosure.
Using cutter to cut the highlighted lines.
fixing the US -sensor in the front of the can to sense when someone is close to the can
Stick cartoon arm to servo to open/close can cover
Mount Servo on the side face of the can such that the arm can open/close the cover.
Mount the LED to indicate the cover opening status
A- Includes and declaration
1- Include library of servo motor , that has customize functions related to servo
2-Create instance from servo
3- Store servo positions
4- Declare variables and assign pin numbers
5- Assign US trigger to pin 7 and echo to pin 6
6- Attach servo to pin 10
8- Set servo initial position to closedPos
9- Set pin 13 as OUTPUT for led
10- Set pin 4 as INPUT for switch
11 - Set trigger pin as OUTPUT , ech pin as INPUT
B- Put US into operation
1- start US sound wave function
2- read travel time using function pulseIn
3- calculate distance using sound speed
C- Main Code
1- if distance < 20 and switch is on
call openTrash() function
and set LED to ON
else
call closeTrash() function
and set LED to OFF
D- Function
1- SendSoundWave() function
set trigger pin to LOW
wait
then set to HIGH
wait
then set to LOW
2- openTrashe() function
reduce position by one degree as long as current position > target position
3- closeTrashe() function
increase position by one degree as long as current position > target position