Check out my two YouTube channels for more content:
- Mrzaizai2k - AI (NEW)
- Mrzaizai2k (Old)
The video below explains the project in detail:
- My Arduino Code: GitHub Repository
- References:
- Overview
- Functions
2.1 Stop (dung())
2.2 Move Forward (tien())
2.3 Move Backward (lui())
2.4 Turn Left (retrai())
2.5 Turn Right (rephai()) - Distance Measurement
This Arduino project controls a robot built with an Arduino Uno, an ultrasonic sensor (HC-SR04), and four DC motors (controlled via the AFMotor library). The robot navigates by measuring distances in front and on its sides, enabling it to stop, move forward, move backward, or turn left and right based on its surroundings.
Stops all motors and displays "DUNG" (Vietnamese for "STOP") on an LCD screen.
Moves the robot forward with customizable speed settings.
Moves the robot backward with adjustable speed.
Turns the robot to the left.
Turns the robot to the right.
- Front Distance (
distancefront()): Uses the HC-SR04 sensor to measure the distance ahead of the robot. - Side Distance (
distanceside()): Measures the distance to the side using the HC-SR04 sensor.
The main program loop continuously measures distances, updates the LCD with the robot's status, and adjusts its movements based on button inputs. The code is flexible, allowing users to tweak motor speeds and distance thresholds to meet specific project needs.
