Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Autonomous Obstacle Avoiding Robot

An Arduino-powered robot that uses an ultrasonic sensor mounted on a servo motor to navigate. It features a robust state-machine logic to scan surroundings and navigate around obstacles efficiently.


πŸ›  Features

  • State-Machine Logic: Replaces messy if-else chains with a clean enum structure.
  • 180Β° Environmental Scanning: Uses a servo to "look" left and right when blocked.
  • Real-time Decision Making: Calculates the best path based on sensor data.
  • Safety Stop: Automatically halts motors to prevent collisions.

πŸ”Œ Pin Configuration

Motor Driver (L298N/L293D)

Component Arduino Pin Function
IN1 D2 Left Motor Forward
IN2 D3 Left Motor Backward
IN3 D4 Right Motor Forward
IN4 D5 Right Motor Backward

Sensors & Servo

Component Arduino Pin
Servo Signal D9
Ultrasonic Trig D13
Ultrasonic Echo D12

πŸ•Ή Logic Flow

The robot follows a systematic "Think-then-Act" process:

  1. Scan Front: Constantly measures distance while moving.
  2. Detection: If an object is detected within 20cm, the robot stops.
  3. Scan Right: Servo turns to 20Β° to check clearance.
  4. Scan Left: If Right is blocked, servo turns to 160Β° to check clearance.
  5. Execute: The robot turns toward the open path and resumes forward movement.

πŸš€ Installation

  1. Clone this repository:
    git clone [https://github.com/yourusername/obstacle-avoiding-robot.git](https://github.com/yourusername/obstacle-avoiding-robot.git)
  2. Open the .ino file in the Arduino IDE.
  3. Ensure the Servo.h library is installed.
  4. Select your board (Arduino Uno) and the correct Port.
  5. Click Upload.

πŸ“ Code Overview

The project is structured using a switch-case state machine:

enum RobotState {
  SCAN_FRONT,
  DECIDE_PATH,
  MOVE_FORWARD,
  STOP_AND_SCAN_RIGHT,
  CHECK_RIGHT,
  TURN_RIGHT,
  SCAN_LEFT,
  CHECK_LEFT,
  TURN_LEFT
};
🀝 Contributing
Contributions are welcome! If you'd like to improve the movement algorithms or add speed control (PWM), feel free to fork the repo and submit a pull request.

About

Ardunino program for obstacle avoiding robot

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages