An Arduino and an ultrasonic sensor along with the servo motor can be integrated to make a smart trashcan. If the bin detects some trash in front of it, it will open its lid automatically and the lid will be closed after a delay of some seconds.
How to Automatically Open and Close the Lid of Dustbin Using Arduino?
Now as we know the abstract of the project, let us move forward and start collecting more information about the components, working and the circuit diagram to immediately start working on the project.
Step 1: Collecting The Components
If you want to avoid any inconvenience in the middle of any project, the best approach is to make a complete list of all the components that we are going to use. The second step, before starting to make the circuit, is to go through a brief study of all these components. A list of all the components that we need in this project is given below.
Step 2: Studying The Components
Now, as we have a complete list of all the components, let us move one step forward and go through a brief study of the working of every component. Arduino Nano is a breadboard-friendly microcontroller board that is used to control or carry out different tasks in a circuit. We burn a C Code on Arduino Nano to tell the microcontroller board how and what operations to perform. Arduino Nano has exactly the same functionality as Arduino Uno but in quite a small size. The microcontroller on the Arduino Nano board is ATmega328p. if you don’t have an Arduino Nano, you can also use Arduino Uno or Arduino Maga. HC-SR04 board is an ultrasonic sensor which is used to determine the distance between two objects. It consists of a transmitter and a receiver. The transmitter converts the electrical signal into an ultrasonic signal and the receiver converts the ultrasonic signal back to the electrical signal. When the transmitter sends an ultrasonic wave, it reflects after colliding with a certain object. The distance is calculated by using the time, that ultrasonic signal takes to go from the transmitter and come back to the receiver. A Servo Motor is a rotatory or a linear actuator which can be controlled and moved in exact increment. These motors are different from DC motors. These motors allow the precise control of angular or rotatory motion. This motor is coupled to a sensor which is sending feedback about its motion.
Step 3: Understanding The Working
We are making a dustbin whose lid will automatically open and close and there will be no need to touch it physically. We will just have to take the trash in front of the trashcan. The Ultrasonic sensor will automatically detect the trash and will open the lid with the help of a servo motor. When the lid is open, we will throw the trash in the bin and when we are done, the lid will be closed automatically after a delay of some seconds. This is the simple working principle behind this project.
Step 4: Assembling The Components
Step 5: Getting Started With Arduino
If you are not already familiar with the Arduino IDE, don’t worry because a step by step procedure to set-up and use Arduino IDE with a microcontroller board is explained below. To download the code, click here.
Step 6: Understanding The Code
The code is pretty well commented but still, it is briefly explained below.
- At the start, a library is included so that we can use built-in functions to operate the servo motor. Two pins of the Arduino Nano board are also initialized so that they can be used for the trigger and echo pin of the ultrasonic sensor. An object is also made so that it can be used to set values for the servo motors. Two variables are also declared so that the value of the distance and time of the ultrasonic signal can be saved and then used in the formula.
- void setup() is a function in which we initialize the pins of the Arduino board to be used as INPUT or OUTPUT. Trigger pin will be used as output and an echo pin will be used as input. We have used the object servo, to connect the motor to pin 5 of the Arduino nano. Pin5 can be used to send the PWM signal. Baud rate is also set in this function. Baud rate is the bits per second speed by which the microcontroller communicates with the external devices.
- void loop() is a function that runs again and again in a loop. In this loop, an ultrasonic wave is sent in the surrounding and received back. The distance covered is measured by using the time taken by the signal to leave the sensor and come back to it. Then the condition is applied to the distance accordingly. Now as we know all the steps to go through to make this amazing project, hurry up and enjoy making your smart trashcan.
How To Make A Smart Stick For Blind People Using Arduino?How To Make A Smoke Alarm For Your Kitchen Using Arduino?How To Make A Digital Thermometer Using Arduino?How To Make Obstacle Avoiding Robot Using Arduino?