Smart Dusbin
Smart Dusbin
Smart Dusbin
1. ABSTRACT:-
2. Introduction to Smart Dustbin using Arduino and Ultrasonic Sensor:-
3. Amazon Purchase Links of the components used in this project.
4. Ultrasonic Sensors:-
4.1. Ultrasonic Sensor Specifications
5. Servo Motor:-
5.1. Micro Servo 9G Specifications
5.2. Basic Information Modulation:
5.3. Additional Specifications
6. Arduino UNO:-
7. What’s on the board?
7.1. Power (USB / Barrel Jack)
7.2. Pins (5V, 3.3V, GND, Analog, Digital, PWM, AREF)
7.3. Reset Button
7.4. Power LED Indicator
7.5. TX RX LEDs
7.6. Main IC
7.7. Voltage Regulator
7.8. OBJECTIVES:-
8. Smart Dustbin Circuit Diagram:-
8.1. CONNECTIONS:-
8.2. Ultrasonic Sensor
9. Pictures of the Components used and the Smart Dustbin:-
10. Smart dustbin Arduino Programming:
10.1. Smart Dustbin Using Arduino Code explanation:
11. Smart Dustbin Project Testing:
ABSTRACT:-
Dustbins (or Garbage bins, Trash Cans, whatever you call them)
are small plastic (or metal) containers that are used to store trash
(or waste) on a temporary basis. They are often used in homes,
offices, streets, parks etc. to collect the waste. In some places,
littering is a serious offence and hence public waste containers
are the only way to dispose small waste. Usually, it is a common
practice to use separate bins for collecting wet or dry, recyclable
or non-recyclable waste.
Tiny and lightweight with high output power. Servo can rotate
approximately 180 degrees (90 in each direction), and works just like the
standard kinds but smaller. You can use any servo code, hardware or
library to control these servos. Good for beginners who want to make
stuff move without building a motor controller with feedback & gear
box, especially since it will fit in small places. It comes with a 3 horns
(arms) and hardware.
Micro Servo 9G Specifications
Weight: 9 g
Dimension: 22.2 x 11.8 x 31 mm approx.
Stall torque: 1.8 kgf·cm
Operating speed: 0.1 s/60 degree
Operating voltage: 4.8 V (~5V)
Dead band width: 10 μs
Temperature range: 0 ºC – 55 ºC Position “0” (1.5 ms pulse) is
middle, “90” (~2ms pulse) is all the way to the left. ms pulse) is all
the way to the right, “”-90″ (~1ms pulse) is all the way to the left.
Basic Information Modulation:
Analog Torque: 4.8V: 25.0 oz-in (1.80 kg-cm)
Speed: 4.8V: 0.10 sec/60°
Weight: 0.32 oz (9.0 g)
Dimensions: Length: 0.91 in (23.1 mm)
Width: 0.48 in (12.2 mm)
Height:1.14 in (29.0 mm)
Motor Type: 3-pole Gear Type: Plastic
Rotation/Support: Bushing
Additional Specifications
Rotational Range: 180°
Pulse Cycle: ca. 20 ms
Pulse Width: 500-2400 µs
Arduino UNO:-
Arduino is an open-source platform used for building electronics
projects. Arduino consists of both a physical programmable circuit board
(often referred to as a microcontroller) and a piece of software, or IDE
(Integrated Development Environment) that runs on your computer, used
to write and upload computer code to the physical board.
The Arduino platform has become quite popular with people just starting
out with electronics, and for good reason. Unlike most previous
programmable circuit boards, the Arduino does not need a separate piece
of hardware (called a programmer) in order to load new code onto the
board — you can simply use a USB cable. Additionally, the Arduino
IDE uses a simplified version of C++, making it easier to learn to
program. Finally, Arduino provides a standard form factor that breaks
out the functions of the micro-controller into a more accessible package.
The Uno is one of the more popular boards in the Arduino family and a
great choice for beginners. The Arduino hardware and software was
designed for artists, designers, hobbyists, hackers, newbies, and anyone
interested in creating interactive objects or environments. Arduino can
interact with buttons, LEDs, motors, speakers, GPS units, cameras, the
internet, and even your smart-phone or you’re TV! This flexibility
combined with the fact that the Arduino software is free, the hardware
boards are pretty cheap, and both the software and hardware are easy to
learn has led to a large community of users who have contributed code
and released instructions for a huge variety of Arduino-based projects.
What’s on the board?
NOTE: Do NOT use a power supply greater than 20 Volts as you will
overpower (and thereby destroy) you’re Arduino. The recommended
voltage for most Arduino models is between 6 and 12 Volts.
Pins (5V, 3.3V, GND, Analog, Digital, PWM, AREF)
The pins on your Arduino are the places where you connect wires to
construct a circuit (probably in conjunction with a breadboard and
some wire. They usually have black plastic ‘headers’ that allow you to
just plug a wire right into the board. The Arduino has several different
kinds of pins, each of which is labeled on the board and used for
different functions.
GND (3): Short for ‘Ground’. There are several GND pins on the
Arduino, any of which can be used to ground your circuit.
5V (4) & 3.3V (5): As you might guess, the 5V pin supplies 5 volts
of power, and the 3.3V pin supplies 3.3 volts of power. Most of the
simple components used with the Arduino run happily off of 5 or
3.3 volts.
Analog (6): The area of pins under the ‘Analog In’ label (A0
through A5 on the UNO) are Analog In pins. These pins can read
the signal from an analog sensor (like a temperature sensor) and
convert it into a digital value that we can read.
Digital (7): Across from the analog pins are the digital pins (0
through 13 on the UNO). These pins can be used for both digital
input (like telling if a button is pushed) and digital output (like
powering an LED).
PWM (8): You may have noticed the tilde (~) next to some of the
digital pins (3, 5, 6, 9, 10, and 11 on the UNO). These pins act as
normal digital pins, but can also be used for something called
Pulse-Width Modulation (PWM). Think of these pins as being able
to simulate analog output (like fading an LED in and out).
AREF (9): Stands for Analog Reference. Most of the time you can
leave this pin alone. It is sometimes used to set an external
reference voltage (between 0 and 5 Volts) as the upper limit for the
analog input pins.
Reset Button
Just like the original Nintendo, the Arduino has a reset button (10).
Pushing it will temporarily connect the reset pin to ground and restart
any code that is loaded on the Arduino. This can be very useful if your
code doesn’t repeat, but you want to test it multiple times. Unlike the
original Nintendo however, blowing on the Arduino doesn’t usually fix
any problems.
Power LED Indicator
Just beneath and to the right of the word “UNO” on your circuit board,
there’s a tiny LED next to the word ‘ON’ (11). This LED should light up
whenever you plug your Arduino into a power source. If this light
doesn’t turn on, there’s a good chance something is wrong. Time to re-
check your circuit!
TX RX LEDs
TX is short for transmit, RX is short for receive. These markings appear
quite a bit in electronics to indicate the pins responsible for serial
communication. In our case, there are two places on the Arduino UNO
where TX and RX appear — once by digital pins 0 and 1, and a second
time next to the TX and RX indicator LEDs (12). These LEDs will give
us some nice visual indications whenever our Arduino is receiving or
transmitting data (like when we’re loading a new program onto the
board).
Main IC
The black thing with all the metal legs is an IC, or Integrated
Circuit (13). Think of it as the brains of our Arduino. The main IC on the
Arduino is slightly different from board type to board type, but is usually
from the ATmega line of IC’s from the ATMEL Company. This can be
important, as you may need to know the IC type (along with your board
type) before loading up a new program from the Arduino software. This
information can usually be found in writing on the top side of the IC. If
you want to know more about the difference between various IC’s,
reading the datasheets is often a good idea.
Voltage Regulator
The voltage regulator (14) is not actually something you can (or should)
interact with on the Arduino. But it is potentially useful to know that it is
there and what it’s for. The voltage regulator does exactly what it says
— it controls the amount of voltage that is let into the Arduino board.
Think of it as a kind of gatekeeper; it will turn away an extra voltage that
might harm the circuit. Of course, it has its limits, so don’t hook up your
Arduino to anything greater than 20 volts.
OBJECTIVES:-
The main objective of this project is to
Ultrasonic Sensor
1. VCC (Sensor) with Arduino 5v
2. Trig (Sensor) with Arduino Pin 7
3. Echo (Sensor) with Arduino Pin 6
4. GND (Sensor) with Arduino GND
Pictures of the Components used and the Smart
Dustbin:-
// Download Servo Library
//https://www.electroniclinic.com/arduino-libraries-download-and-
projects-they-are-used-in-project-codes/
#include <Servo.h>
// Defines Tirg and Echo pins of the Ultrasonic Sensor
const int trigPin = 6;
const int echoPin = 7;
// Variables for the duration and the distance
long duration;
int distance;
Servo myServo; // Creates a servo object for controlling the servo motor
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600);
myServo.attach(9); // Defines on which pin is the servo motor attached
}
void loop() {
// rotates the servo motor from 15 to 165 degrees
for (int i = 15; i <= 165; i++) {
myServo.write(i);
delay(30);
distance = calculateDistance();// Calls a function for calculating the
distance measured by the Ultrasonic sensor for each degree
Serial.print(i); // Sends the current degree into the Serial Port
Serial.print(","); // Sends addition character right next to the previous
value needed later in the Processing IDE for indexing
Serial.print(distance); // Sends the distance value into the Serial Port
Serial.print("."); // Sends addition character right next to the previous
value needed later in the Processing IDE for indexing
}
// Repeats the previous lines from 165 to 15 degrees
for (int i = 165; i > 15; i--) {
myServo.write(i);
delay(30);
distance = calculateDistance();
Serial.print(i);
Serial.print(",");
Serial.print(distance);
Serial.print(".");
}
}
// Function for calculating the distance measured by the Ultrasonic
sensor
int calculateDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the
sound wave travel time in microseconds
distance = duration * 0.034 / 2;
return distance;
}
Smart Dustbin Using Arduino Code explanation:
I started off, by adding the Servo.h header file. The Servo library download link is
already given above.
#include <Servo.h>
Next I defined pins for the Trigger and Echo. The Trigger and Echo pins of the HC-
SR04 Ultrasonic Sensor are connected with the Arduino’s pins 6 and 7 respectively.
long duration;
int distance;
Servo myServo; // Creates a servo object for controlling the servo motor
Every Arduino Uno, Arduino Nano, Arduino Mega, etc have at least two functions, which
are the void setup() and void loop() functions. Void means that these functions are not
returning any values, while the empty parenthesis means that these functions does not
take any arguments as the input.
The setup() function runs only one time with the Arduino board is turned ON.
void setup() {
Serial.begin(9600);
void loop() {
myServo.write(i);
delay(30);
Serial.print(i); // Sends the current degree into the Serial Port
Serial.print(“,”); // Sends addition character right next to the previous value needed
later in the Processing IDE for indexing
Serial.print(distance); // Sends the distance value into the Serial Port
Serial.print(“.”); // Sends addition character right next to the previous value needed
later in the Processing IDE for indexing
}
// Repeats the previous lines from 165 to 15 degrees
myServo.write(i);
delay(30);
Serial.print(i);
Serial.print(“,”);
Serial.print(distance);
Serial.print(“.”);
}
int calculateDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave
travel time in microseconds
return distance;
All the Serial.println() functions used in the above programming can be commented or
deleted. These functions are only used for the debugging purposes.
REFRENCE:
1. https://www.electroniclinic.com/smart-dustbin-
using-arduino-ultrasonic-sensor-and-servo-
motor/.
2.