Learn Robotics with Raspberry Pi — Part 4: Putting Everything Together

Neel Kumar
Aug 2, 2021

--

Summary

This blog contains the code to integrate the motors, and sensors to finish the robot.

Code

This is the code from ObstacleAvoidance.py

Import the libraries and functions from other programs:

Setup all of the sensors and motors

Turn until clear (turns until all of the sensors don’t detect anything):

Start ultrasonic thread and start moving forward:

Start the main while loop and other pieces of code to print error, handle KeyboardInterrupts, and do some cleanup at the end:

Congratulations

You have made an obstacle avoidance robot, but more than that, this is just the beginning of your robotics journey. I hope you continue doing robotics and solve a problem with it someday, good luck!

Part 1: Overview

Part 2: Motors and Chassis

Part 3: Sensors

Part 4: (This Article) Putting everything together

--

--