Project Type: Class Project, MEE 625
Contributors: Amit Chaudhary, Fazel Hayatt Khan,
Date: October 2025
This project developed an autonomous mobile robot that travels through an indoor environment while detecting and avoiding nearby obstacles. A Raspberry Pi 5 runs the Python control program, interfaces with the sensors and motors through GPIO, and makes navigation decisions in real time.
The robot uses two HC-SR04 ultrasonic sensors. A fixed lower sensor continuously checks the path directly ahead, while an upper sensor mounted on an SG90 servomotor scans both sides when an obstacle is detected. The controller compares the measured clearances and turns toward the side with more open space.
Motor direction and speed are controlled through a TB6612 driver. A 1 kHz PWM signal sets the motor duty cycle, and the robot operates primarily at 50 percent duty cycle for forward, reverse, and pivot-turn motions. This architecture combines sensing, decision-making, and actuation in a continuous feedback loop.
The lower HC-SR04 sensor monitors the immediate path ahead. The upper HC-SR04 sensor rotates with the SG90 servo to compare left and right clearances before the robot selects a turning direction.
The controller uses the following sensor and control inputs:
Forward distance from the fixed lower ultrasonic sensor
Left- and right-side clearances from the servo-mounted ultrasonic sensor
Obstacle threshold of 20 cm
PWM frequency of 1 kHz and tuned motor duty-cycle values
The obstacle-avoidance routine operates as a continuous sensing and motion cycle:
Initialize the hardware. Configure the GPIO pins, ultrasonic sensors, SG90 servo, TB6612 motor driver, and 1 kHz PWM channels.
Move forward by default. Drive both motors forward at approximately 50 percent duty cycle while the path remains clear.
Measure the forward clearance. Continuously read the fixed lower HC-SR04 sensor and compare the measured distance with the 20 cm threshold.
Stop and scan when an obstacle is close. If the forward distance falls below 20 cm, interrupt forward motion and rotate the upper sensor to examine both sides.
Compare left and right distances. Record the two upper-sensor measurements and identify which side provides the greater open distance.
Perform a pivot turn. Run the left and right motors in opposite directions at 50 percent duty cycle to turn toward the clearer side.
Resume autonomous motion. Return the scanning sensor to its forward position, continue driving, and repeat the feedback loop as new obstacles are encountered.
The completed robot performs real-time obstacle avoidance using two ultrasonic distance sensors. It moves autonomously, detects objects within the defined safety threshold, scans both sides, selects the direction with greater clearance, and resumes forward motion without manual control.
Development highlighted several practical integration issues:
The compact platform required separate power sources: a 5 V / 2.3 A power bank for the Raspberry Pi 5 and a smaller 9 V battery for the motors.
A custom 3D-printed mount supported the scanning sensor.
Longer wires were used to correct unstable connections while fitting the sensors, controller, batteries, and wiring within the chassis.
Thank you for reading! Please check out my other projects as well, and let me know if you have any suggestions for improvement.