Step 1: Circuit ConnectionsArduino to L298N Motor Driver
Motor A (Left Wheels) β L298N OUT1 & OUT2
Motor B (Right Wheels) β L298N OUT3 & OUT4
L298N IN1, IN2 β Arduino Digital Pins 5, 6
L298N IN3, IN4 β Arduino Digital Pins 9, 10
L298N VCC β 12V Battery
L298N GND β Common GND with Arduino
L298N 5V Output β Arduino 5V
IR Sensors to ArduinoLeft IR Sensor β A0
Right IR Sensor β A1
Additional IR Sensors for obstacle detection β A2, A3
Ultrasonic Sensor to ArduinoTrig Pin β Digital Pin 7
Echo Pin β Digital Pin 8
Servo Motor to ArduinoSignal Pin β Digital Pin 3
VCC β 5V
GND β GND
Use the Arduino IDE to upload the code. Ensure you have installed the NewPing library for ultrasonic sensor functionality.
Key Code Features:Mode Selection: Line Following, Obstacle Avoidance, Combined Mode, and Object Following.
Motor Control Functions: rotateMotor() handles speed and direction.
Sensor Calibration: Adjust IR sensor sensitivity.
Servo and Ultrasonic Integration: Moves sensor to detect objects dynamically.
Step 3: Testing and CalibrationCalibrate IR Sensors: Ensure they properly detect lines.
Adjust Motor Speed: Modify PWM values if needed.
Battery Considerations: Use a LiPo battery for stable operation.
Fine-tune Ultrasonic Sensor Positioning: Adjust servo angles for better detection.








Comments