Supplies

Supplies

Supplies

Raspberry Pi Pico x1 

Buck Converter Module x1

  • Since the maximum voltage that all the hardware I'm using can withstand is 5V, and the battery I currently have is 7.4V, I have decided to use a voltage regulator module to help me provide a stable 5V power supply.

L9110 Motor Driver Module x1 

Infrared Proximity Sensor-GP2Y0A21YK0F x2

  • I need to use two of these modules because I need to use them to detect if the person it's following is making a left or right turn. When a left turn occurs, the infrared module fixed on the left side will detect an object, while the one on the right will not. At this point, the main control chip will control the trash can to turn left.

HC-SR04 Ultrasonic Sensor Module x2 

  • I use it to detect the distance between the trash can and the person it's following. When the distance exceeds 20cm, the wheels of the trash can start moving, trying to maintain a distance of 15-20cm from the person it's following.

Robot Car Chassis x1

Useless Box x1 

Battery x1 

SG90 Servo Motor x1 

Switch Button x1 

Breadboard x1 

Dupont Wires xN 

Step 1: Make a Cardboard Box for Our Car

Make a Cardboard Box for Our Car

Make a Cardboard Box for Our Car

Make a Cardboard Box for Our Car

First, find a cardboard box that is roughly the same size as the robot car chassis. Then, use scissors to cut holes on the bottom of the cardboard box for the three wheels and motors of the car. This process requires extreme caution and attention to safety. It's best to measure and cut slowly, so as not to cut too much or accidentally damage the box.After making the box, we can place the robot car chassis inside it and use screws and nuts to secure the chassis to the cardboard box.

Step 2: Connect the Circuit According to the Circuit Diagram

Connect the Circuit According to the Circuit Diagram

Connect the Circuit According to the Circuit Diagram

Connect the Circuit According to the Circuit Diagram

If you take a look at the circuit diagram for this project, you'll see that it's actually pretty simple. You only need 5 modules, and there are only 14 wires to connect (not counting the power and ground connections). Once you've connected the wires, you just need to fix the modules in place.

I attached two infrared proximity sensor modules to the left and right sides of the cardboard box to detect if the object being followed is turning left or right. Then, I fixed the ultrasonic sensor module in the middle of the front of the cardboard box to detect the distance between the car and the object in front of it. I even made two holes in the box to make it look like a cute pig's nose!

I also placed an ultrasonic sensor module on the edge of the box lid to detect if the lid is open. This placement allows for more accurate detection.

As for the servo motor, I fixed it inside the box and attached it to a disposable chopstick with hot melt glue to make it long enough to open the lid.

I've included some pictures of my building process below. Check them out!

Step 3: Arduino Programming

This project may appear complex at first glance, but in reality, the code is quite simple. It involves collecting data from the sensor modules, processing it, and then controlling the movement of the car's wheels based on that data. The source code for the entire project will be provided at the end of the article. In the following sections, I will explain the code line by line, so that you can quickly understand and create your own automatic follow-me trash can.

#include "Ultrasonic.h"#include "wheel.h"#include "RPi_Pico_TimerInterrupt.h"#include <Servo.h> 

The above code is the header file section of the Arduino code for the project. It includes the necessary libraries for the project,...

Read more »