HC-SR04 ultrasonic sensor
The HC-SR04 ultrasonic sensor is used in the Smart Dustbin Robot to detect the distance between the dustbin and an approaching hand or object. It works by sending a short burst of ultrasonic sound waves through its Trig pin and receiving the reflected waves through its Echo pin. By measuring the time taken for the sound waves to travel to the object and return, the Arduino Uno can calculate the distance.

The sensor normally has four pins: VCC, Trig, Echo, and GND. VCC is connected to the power supply, GND to ground, and the Trig and Echo pins are connected to digital pins of the Arduino Uno. The Arduino sends a trigger pulse and measures the duration of the returning echo signal to determine how close the object is.
In the small Smart Dustbin Robot, the HC-SR04 can be positioned near the top or front of the dustbin. When a hand comes within a programmed distance, such as 15–20 cm, the Arduino detects it and activates the servo motor to open the lid automatically. After the hand moves away and a short delay, the lid can close again, creating a simple touch-free waste-disposal system.