Connections
The Arduino Uno acts as the main controller of the DIY obstacle-avoiding robot. Connect the HC-SR04 ultrasonic sensor to the Arduino with VCC → 5V, GND → GND, TRIG → a digital output pin, and ECHO → a digital input pin. The sensor continuously measures the distance between the robot and an object. The Arduino processes this distance information and decides whether the robot should continue moving or change direction.
The motor driver module provides the required current to operate the two DC gear motors. Connect the motor driver’s IN1, IN2, IN3, and IN4 control inputs to four Arduino digital pins. Connect the left motor to one motor-output pair and the right motor to the other output pair. The motor driver receives its motor power from the battery through its positive and negative power terminals, while the Arduino and motor driver must have a common GND. The exact Arduino pins can be selected according to the program being used.
The two DC gear motors and wheels are connected to the motor-driver outputs. One motor drives the left wheel and the other drives the right wheel. When both motors rotate forward, the robot moves forward; reversing both motors moves it backward. By running one motor faster than the other, or by rotating the motors in opposite directions, the robot can turn left, turn right, or rotate in place. The caster wheel is mechanically attached to the chassis and normally requires no electrical connection.
The battery pack supplies electrical power to the robot. Its output should be connected to the motor driver’s power input according to the voltage requirements of the selected motors and driver. The Arduino can be powered through an appropriate regulated supply or its recommended power input. Before switching on the robot, check the polarity of every connection, ensure that all grounds are common where required, and verify that the battery voltage is suitable for each component. With these connections, the Arduino can read the ultrasonic sensor, control the motor driver, and automatically change the robot’s movement whenever an obstacle is detected.