Automating Trash Disposal with Arduino Trash-Bot

13 May 2023 Balmiki Mandal 0 µC - µP

Introducing The Arduino Trash-Bot: Auto-Open and Close Your Trash Bin

Are you tired of having to open and close your trash can every time you need to throw something away? If so, the revolutionary Arduino Trash-Bot is just what you need! This innovative device is designed to automatically open and close your trash bin with the simple press of a button.

The Trash-Bot utilizes a powerful Arduino microcontroller, a series of servo motors, and a roll of plastic tape to open and close your trash can lid. The servo motors are connected to the microcontroller via a series of cables and are controlled by a set of commands programmed into the Arduino. The roll of plastic tape is used to attach the Trash-Bot motor to the lid of the trash can in order to actuate it open and shut.

Using the Trash-Bot is uncomplicated. Simply plug the device into a power source, mount the motor to the top of your trash can using the included plastic tape, and follow the initial setup instructions. Once that's done, you can easily control the Trash-Bot by pressing a single button.

Thanks to the Arduino Trash-Bot, you no longer have to worry about manually opening and closing your trash can ever again. Get yours today and start enjoying the convenience of this amazing device!

 

Here is a sample code that can be used to create an Arduino Trash-Bot that automatically opens and closes the trash bin lid:

#include <Servo.h>

// Define servo pin
const int servoPin = 9;

// Define sensor pin
const int sensorPin = A0;

// Define sensor threshold value
const int sensorThreshold = 500;

// Initialize servo object
Servo servo;

void setup() {
  // Attach servo to servo pin
  servo.attach(servoPin);

  // Initialize serial communication
  Serial.begin(9600);

  // Set sensor pin as input
  pinMode(sensorPin, INPUT);
}

void loop() {
  // Read sensor value
  int sensorValue = analogRead(sensorPin);

  // Print sensor value to serial monitor
  Serial.print("Sensor value: ");
  Serial.println(sensorValue);

  // If sensor value is below threshold, open the lid
  if (sensorValue < sensorThreshold) {
    openLid();
  }
  // Otherwise, close the lid
  else {
    closeLid();
  }
}

// Function to open the lid
void openLid() {
  servo.write(180);
  delay(1000);
}

// Function to close the lid
void closeLid() {
  servo.write(0);
  delay(1000);
}

In this code, we are using an IR sensor to detect the presence of trash in the bin and a servo motor to open and close the lid. The IR sensor is connected to an analog pin on the Arduino board and the servo motor is connected to a digital pin.

In the setup() function, we attach the servo to the servo pin, initialize the serial communication, and set the sensor pin as an input.

In the loop() function, we read the sensor value using the analogRead() function and print it to the serial monitor. We then check if the sensor value is below the threshold value by comparing it to sensorThreshold. If the sensor detects trash, we call the openLid() function to open the lid. Otherwise, we call the closeLid() function to close the lid.

The openLid() function sets the servo position to 180 degrees, which should open the lid, and waits for 1 second using the delay() function.

The closeLid() function sets the servo position to 0 degrees, which should close the lid, and waits for 1 second using the delay() function.

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.