Obstacle Avoiding Robot

My project is an obstacle avoiding robot using raspberry pi. It uses raspberry pi so it can take pictures of the obstacles it faces. I then combine my previous project and detect smiles.


Ameya G

Area of Interest

Electrical and Mechanical Engineering


Homestead High School


Incoming Sophomore

Third Milestone

For my third milestone I started to make connections between the raspberry pi, ultrasonic sensor, battery pack, and motor driver. I found errors in my code and it took a very long time for me to actually get the robot to move at all. I learned about duty cycles and frequency, which was the reason my robot was not working. I had to figure out the correct number for both of them and then my robot began to move. I was super excited that my robot was finally working so I added code for the ultrasonic sensor into my program. However, I realized that the ultrasonic sensor wasn’t detecting anything at all. I tested it on arduino code which I knew worked previously. It turned out that my ultrasonic sensor was broken so I needed a solution quickly. I found an infrared sensor in my bag and used that for obstacle detection. Infrared sensors can’t measure distances in centimeters so there was a set distance away that it would detect. My next step was using the picamera to take a picture as soon as the infrared sensor detected an obstacle. That was fairly easy and it didn’t take long for me to write the code for. I decided I would take the pictures and then feed them into the smile recognition model because otherwise it would take too long. I got some really cool images and I was able to detect a smile from the camera in the program.

Output from the camera and smile recognition

Second Milestone

For my second milestone I got my robot to avoid obstacles using arduino as the microcontroller. I had to wire the ultrasonic sensor using a wiring diagram I found online. I used a breadboard to make wiring a little easier and to give the ultrasonic sensor a steady base. One of the hardest things was getting the power from the battery to both the motor shield and the arduino. I then had to wire inputs from the arduino to the motor driver so it would tell the motors what to do. I learned about PWM which takes a digital signal and makes it into an analog signal. I had to use PWM for the speed of the motors. I had to change the code a little because I had used a different motor shield than the tutorial. It didn’t take that long and when I finished, I had an amazing obstacle avoiding robot. The next part was coding the raspberry pi so it could take over as the microcontroller. I learned about GPIO which was the row of pins on the raspberry pi. It made everything so much easier. I started to implement code from my previous project into the raspberry pi code I had created. The next step would be to start wiring the raspberry pi to the motor driver and ultrasonic sensor. If I have time later I would like to look into serializing my training model to make the robot program faster.

First Milestone

For my first milestone I built the chassis for my robot, and attached the battery holder and the motor to it. When I got the supplies to my project the first thing I had to do was build the chassis. I struggled finding which parts go where. I googled how to build the chassis and found one that was pretty close to the one I was doing. The first thing i had to do was attach two plates to the motors so that the motors would be securely attached to the chassis as the motor is extremely important to movement. I attached the wheels to the motor and then attached a tiny wheel at the bottom so that the robot isn’t just balancing on two wheels. I used 4 brass standoffs for a different platform where my microcontroller, batteries, ultrasonic sensor and motor driver would go. I had to attach a section of a milk carton to the back because there was not enough space on the platform. I am now wiring things together and have started by wiring the ultrasonic sensor to the arduino. Wiring has been the hardest thing so far, because it is hard to see where all the wires go.

Leave a Comment

Start typing and press Enter to search

Bluestamp Engineering