Automatic Trash Bin

The Automatic Trash Bin project makes life easier, implementing robotics into real life. 100 RPM BDC Motor with Encoder and the Ultrasonic Distance Sensor Module is used to detect and move the trash bin lid. An approaching person or a hand activates the system, the motor actuates and the lid opens.

About Tools and Materials:

SMD Red (Robot Shop)

SMD USB Gateway (Robot Shop)

Ambient Light Sensor Module (Robot Shop)

100 RPM BDC Motor with Encoder (Robot Shop)

Step 1: Hardware & Software Overview

Project Key Components

Project Key Features

  • Hands-free Operation

    The Ultrasonic Distance Sensor Module makes it easy in terms of hygiene and automation, automatic trash bin lid project makes life easier.

  • Adjustable Sensitivity

    The script include parameters that can be edited by the user to change the sensivity of the system, it helps to avoid unwanted activations of the BDC motor.

Step 2: Assemble

  1. Hardware Setup

Project Wiring Diagram

Step 3: Run & Test

  1. Run the Script

    • Execute the script, initiating the Automatic Trash Bin application.

    • Approach the trash bin, and observe how the lid opens automatically when the user is in close proximity.

  2. Enhance and Customize

    • Fine-tune the sensitivity parameters in the script based on the user feedback and the specific requirements of the environment.

    • Explore additional features, such as automatic lid closing after a specified period or incorporating status indicators.

Project Codes:

from smd.red import *

SerialPort = "COM3"         # Serial port of the USB gateway module
baudrate = 115200           # Baud rate of communication
ID = 0                      # ID of the SMD
distance_id = 1             # ID of the ultrasonic distance sensor module

master = Master(SerialPort, baudrate)       # Defines the USB gateway module
master.attach(Red(ID))                      # Gives acces to the SMD of specified ID

master.set_shaft_rpm(ID, 100)                               # Sets the RPM value of the motor
master.set_shaft_cpr(ID, 6533)                              # Sets the CPR value of the motor

master.set_operation_mode(ID, 1)                            # Sets the operation mode to 'Position Control'
master.set_control_parameters_position(ID, 10, 0, 50)       # Sets the PID parameters, can be auto-tuned instead
master.enable_torque(ID, 1)                                 # Enables the motor to spin if any command say so

while True:
    distance = master.get_distance(ID, distance_id)         # Variable to store the distance data
    print(distance)                                         # Printing the value to observe

    if distance < 10:                       # If it sees a person nearby 10 cm
        master.set_position(ID, 1000)       # Motor lifts the trash bin lid, change position value if it doesn't lift
        time.sleep(2)

    else:                               
        master.set_position(ID, 0)          # Motor puts the lid down

Last updated