Automatic Trash Bin

The Automatic Trash Bin application is a Python-based project that employs an SMD Motor Driver, a DC Motor, and an add-on HC-SR04 Ultrasonic Module to create a hands-free and hygienic solution for waste disposal. This innovative project allows the trash bin lid to open automatically when a user approaches, enhancing convenience and promoting a touch-free experience.

Project Key Components:

  1. SMD Motor Driver:

    • The SMD Motor Driver serves as the communication interface between the Python script and the DC Motor. It interprets commands from the script and translates them into actions that control the movement of the trash bin lid.

  2. DC Motor:

    • The DC Motor is connected to the SMD Motor Driver and is responsible for physically opening and closing the trash bin lid.

  3. HC-SR04 Ultrasonic Module:

    • The HC-SR04 Ultrasonic Module is integrated into the project to measure the distance between the module and a user approaching the trash bin. This module provides real-time feedback to the Python script for triggering the automatic lid-opening mechanism.

  4. Python Script:

    • The Python script is the central component of the application. It continuously monitors the distance readings from the HC-SR04 Ultrasonic Module and sends commands to the SMD Motor Driver to open or close the trash bin lid based on user proximity.

Project Key Features:

  1. Hands-Free Operation:

    • The Automatic Trash Bin eliminates the need for users to touch the bin lid, providing a hygienic and hands-free waste disposal experience.

  2. Proximity-Based Lid Control:

    • The HC-SR04 Ultrasonic Module detects the presence of a user in close proximity to the trash bin. When a user approaches, the Python script commands the DC Motor to open the lid automatically.

  3. Adjustable Sensitivity:

    • The Python script may include parameters to adjust the sensitivity of the lid-opening mechanism. This allows customization based on user preferences and the specific environment in which the trash bin is placed.

Project Wiring Diagram:

Getting Started:

  1. Hardware Setup:

    • Connect the DC Motor to the SMD Motor Driver according to the provided documentation.

    • Integrate the HC-SR04 Ultrasonic Module into the trash bin setup, ensuring secure connections.

  2. Run the Python Script:

    • Execute the Python 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.

  3. Enhance and Customize:

    • Fine-tune the sensitivity parameters in the script based on 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 board
distance_id = 1             # ID of the ultrasonic distance 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, 8)        # 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