Automatic waste basket with arduino nano

In this tutorial we will see how to create an automatic garbage basket, with arduino nano an ultrasonic sensor, an sg90 servo motor and other electronic components. It includes the source code, electronic diagram and gerber file for printed circuit design, all totally free of charge.

You may be interested in projects in Arduino, pic, robotics, telecommunications, subscribe videos with full source code and diagrams


Project electronic circuit

Project materials

Servo sg90: Features

  • Dimensions (L x W xH) x 22.0 x 11.5 x 27 mm (0.86 x 0.45 x 1.0 inches)
  • Weight: 9 grams
  • Wired and connector weight: 10.6 grams
  • Torque at 4.8 volts: 16.7 oz/in or 1.2 kg/cm
  • Operating voltage: 4.0 to 7.2 volts
  • Turning speed at 4.8 volts: 0.12 sec / 60 o
  • Universal connector for most radio control receivers
  • Compatible with cards like Arduino and microcontrollers that work at 5 volts.

How to control a servo motor?

You can place the servo shaft at various angles from 0 to 180o. Servos are controlled using a pulse width modulation (PWM) signal. This means that the PWM signal sent to the motor will determine the position of the shaft.

Arduino Nano

The Arduino Nano is a small board, complete and compatible with the test board based on the ATmega328 (Arduino Nano 3.x). It has about the same functionality as the Arduino Duemilanove, but in a different package. It only lacks a DC power connector and works with a Mini-B USB cable instead of a standard one.

Microcontroller ATmega328
Architecture Avr
Operating voltage 5 V
Flash memory 32 KB of which 2 KB uses the bootloader
Sram 2 KB
Clock speed 16 MHz
Analog pins IN 8
Eeprom 1 KB
DC current by I/O pins 40 mA (I/O pins)
Input voltage 7-12 V
Digital I/O Pins 22 (6 of which are PWM)
PWM output 6
Energy consumption 19 mA
PCB size 18 x 45 mm
Weight 7g

Pin diagram

HC-SR04 Ultrasound Sensor Module

The HC-SR04 sensor is an excellent choice as an ultrasonic distance sensor. Its cost-benefit ratio makes it

optimal for a wide range of applications. The use of this module is quite simple because all

the control, transmission and reception electronics are contained in PCB. The user should only send a trigger pulse and

measure in high response pulse time. Only 4 cables are required to complete the interface with the HC-SR04 sensor module. The HC-SR04 is

compatible with most microcontrollers on the market, including the Arduino UNO,

Arduino MEGA and other compatible cards that work with 5 volts. There are libraries for this module that make the part of the software very simple. We

recommend purchasing some Dupont type cables to be able to use this sensor without welding.
It has two transducers: a piezoelectric emitter and receiver, in

addition to the electronics necessary for its operation. The operation of the sensor is as follows: the piezoelectric emitter emits 8

pulses of ultrasound(40KHz) after receiving the order on the TRIG

pin, the sound waves travel in the air and bounce when an object is found, the bounce

sound is detected by the piezoelectric receiver, then the ECHO pin changes to

High (5V) for a time equal to the time it delayed the wave from the time it was emitted until it was detected, the ECHO pulse time is measured by the microcontroller and so the distance to the object can be calculated. Sensor operation is not affected by sunlight or black material (although

soft materials aqueously such as fabric or wool can become difficult to detect).


-Simple interface: Only

4 cables

-Operating voltage: 5V DC -Sleep current: <


-Working current: 15mA -Measurement range: 2cm to 450cm

-Accuracy: +- 3mm

-Opening angle: 15o

-Ultrasound frequency: 40KHz

-Minimum duration of TRIG trigger pulse (TTL level): 10

S -Output ECO Pulse Duration (TTL Level): 100-25000’S

-Dimensions: 45mm x 20mm x 15mm

-Minimum waiting time between one measurement and the start of another 20ms (recommended 50ms)


-VCC (+5V

DC) -TRIG (Ultrasound Shot)


(Ultrasound Reception) -GND (0V)

A 1K Resistor

A 5mm red LED diode

An ice cream stick

Three-pin Macho

Two nuts and screws

Waste basket

A Zocalo for Arduino

PCB Printed Circuit

Gerber file –> Gerber_CESTO_DE_RESIDUOS

Source code


[wysija_form id=”1″]


Deja una respuesta