═══════════════════════════════════════════════════════════════════════════════ ARDUINO SMART ROBOT - COMPLETE WIRING QUICK REFERENCE GUIDE Ultrasonic Radar + Line Following System ═══════════════════════════════════════════════════════════════════════════════ ╔════════════════════════════════════════════════════════════════════════════╗ ║ POWER DISTRIBUTION DIAGRAM ║ ╚════════════════════════════════════════════════════════════════════════════╝ Battery Pack (7.4V) │ ┌──────┴──────┐ │ │ (+) │ │ (-) ↓ ↓ ┌─────────────────────┐ │ L298N Module │ │ Motor Driver │ │ +12V input (7.4V) │ │ GND connection │ └──────┬────┬────┬────┘ │ │ │ ┌────────┘ │ └────┐ │ │ │ Motor 1(Left) Motor2(Right) Motor3(Rear) 6V 200RPM 6V 200RPM 6V 200RPM Arduino 5V ──→ Sensors + Servo (Low Power Only) Arduino GND ──→ Common with Battery GND ╔════════════════════════════════════════════════════════════════════════════╗ ║ ARDUINO UNO PIN CONFIGURATION - DETAILED MAP ║ ╚════════════════════════════════════════════════════════════════════════════╝ ┌─────────────────────────────────────────────────────────────────────────────┐ │ DIGITAL PINS (0-13) │ ├─────────────────────────────────────────────────────────────────────────────┤ │ Pin 0 (RX) │ Serial Input (RESERVED - Do Not Use) │ │ Pin 1 (TX) │ Serial Output (RESERVED - Do Not Use) │ │ Pin 2 │ L298N IN1 (Motor 1 Direction A) ●●● │ │ Pin 3 (PWM) │ L298N IN2 (Motor 1 Direction B) ●●● │ │ Pin 4 │ L298N IN3 (Motor 2 Direction A) ●●● │ │ Pin 5 (PWM) │ L298N IN4 (Motor 2 Direction B) ●●● │ │ Pin 6 (PWM) │ FREE - Available for expansion │ │ Pin 7 │ HC-SR04 TRIG (Ultrasonic Trigger) ●●● │ │ Pin 8 │ HC-SR04 ECHO (Ultrasonic Echo) ●●● │ │ Pin 9 (PWM) │ SG90 Servo Signal (Sensor Rotation) ●●● │ │ Pin 10 (PWM) │ L298N ENA (Motor 1 Speed Control) ●●● │ │ Pin 11 (PWM) │ L298N ENB (Motor 2 Speed Control) ●●● │ │ Pin 12 │ FREE - Available for expansion │ │ Pin 13 (LED) │ Built-in LED (Debugging only) │ └─────────────────────────────────────────────────────────────────────────────┘ ┌─────────────────────────────────────────────────────────────────────────────┐ │ ANALOG PINS (A0-A5) │ ├─────────────────────────────────────────────────────────────────────────────┤ │ A0 │ LEFT LINE SENSOR (Analog Input) ●●● │ │ A1 │ RIGHT LINE SENSOR (Analog Input) ●●● │ │ A2 │ FREE - Available for expansion │ │ A3 │ FREE - Available for expansion │ │ A4 │ FREE - Available for I2C SDA (I2C devices) │ │ A5 │ FREE - Available for I2C SCL (I2C devices) │ └─────────────────────────────────────────────────────────────────────────────┘ ┌─────────────────────────────────────────────────────────────────────────────┐ │ POWER PINS │ ├─────────────────────────────────────────────────────────────────────────────┤ │ 5V │ For Sensors & Servo Power (LIMITED: ~500mA max) │ │ 3.3V │ Not used in this project │ │ GND (2x) │ Common Ground with Battery (CRITICAL for all circuits) │ └─────────────────────────────────────────────────────────────────────────────┘ ╔════════════════════════════════════════════════════════════════════════════╗ ║ DETAILED COMPONENT CONNECTION CHECKLIST ║ ╚════════════════════════════════════════════════════════════════════════════╝ ┌─ HC-SR04 ULTRASONIC SENSOR ─────────────────────────────────────────────────┐ │ │ │ HC-SR04 Pin │ Arduino Pin │ Color/Description │ │ ─────────────┼─────────────────┼────────────────────────────── │ │ VCC │ Arduino 5V │ Red wire (Power supply) │ │ GND │ Arduino GND │ Black wire (Ground) │ │ TRIG │ Pin 7 │ Yellow wire (Trigger pulse) │ │ ECHO │ Pin 8 │ Blue wire (Echo response) │ │ │ │ Function: Measures distance to obstacles (0-400cm range) │ │ Mounting: Top front of chassis, pointing forward │ │ Attached to: SG90 servo motor bracket for 360° scanning │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─ LINE SENSOR #1 (LEFT) ──────────────────────────────────────────────────────┐ │ │ │ Sensor Pin │ Arduino Pin │ Description │ │ ─────────────┼─────────────────┼────────────────────────────── │ │ VCC │ Arduino 5V │ Power supply │ │ GND │ Arduino GND │ Ground │ │ OUT (Analog) │ A0 │ Sensor output signal │ │ │ │ Function: Detects black/white line beneath robot (analog 0-1023) │ │ Mounting: Bottom left of chassis, 2cm from ground │ │ Range: ~1-2cm above white/black surfaces │ │ Calibration: Adjust potentiometer for optimal threshold │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─ LINE SENSOR #2 (RIGHT) ─────────────────────────────────────────────────────┐ │ │ │ Sensor Pin │ Arduino Pin │ Description │ │ ─────────────┼─────────────────┼────────────────────────────── │ │ VCC │ Arduino 5V │ Power supply │ │ GND │ Arduino GND │ Ground │ │ OUT (Analog) │ A1 │ Sensor output signal │ │ │ │ Function: Detects black/white line beneath robot (analog 0-1023) │ │ Mounting: Bottom right of chassis, 2cm from ground │ │ Spacing: 4-5cm apart from left sensor for better line tracking │ │ Calibration: Adjust potentiometer for optimal threshold │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─ SG90 SERVO MOTOR ───────────────────────────────────────────────────────────┐ │ │ │ Servo Wire │ Arduino Pin │ Color/Description │ │ ─────────────┼─────────────────┼────────────────────────────── │ │ GND │ Arduino GND │ Brown wire (Ground) │ │ VCC │ Arduino 5V │ Red wire (5V Power) │ │ SIGNAL │ Pin 9 (PWM) │ Orange wire (Control signal) │ │ │ │ Function: Rotates ultrasonic sensor bracket for 360° scanning │ │ Angle Range: 0° (left) to 180° (right) │ │ Speed: ~60°/second │ │ Power: 5V, 100-200mA at stall │ │ Mounting: Center-top of chassis, base secured with metal bracket │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─ L298N MOTOR DRIVER MODULE ──────────────────────────────────────────────────┐ │ │ │ L298N Pin │ Connection │ Description │ │ ─────────────┼────────────────┼────────────────────────────── │ │ GND │ Battery GND │ Common ground (CRITICAL) │ │ +12V (+5V) │ Battery +7.4V │ Motor power supply │ │ │ │ IN1 │ Arduino Pin 2 │ Motor 1 Direction A (Forward) │ │ IN2 │ Arduino Pin 3 │ Motor 1 Direction B (Backward) │ │ IN3 │ Arduino Pin 4 │ Motor 2 Direction A (Forward) │ │ IN4 │ Arduino Pin 5 │ Motor 2 Direction B (Backward) │ │ │ │ ENA │ Arduino Pin 10 │ Motor 1 Speed Control (PWM 0-255) │ │ ENB │ Arduino Pin 11 │ Motor 2 Speed Control (PWM 0-255) │ │ │ │ OUT1 & OUT2 │ Motor 1 │ Left motor connection │ │ OUT3 & OUT4 │ Motor 2 │ Right motor connection │ │ │ │ Function: Amplifies Arduino signals to drive DC motors │ │ Max Current: 2A per channel │ │ Mounting: Near motors to minimize wire length │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─ DC GEAR MOTOR #1 (LEFT WHEEL) ──────────────────────────────────────────────┐ │ │ │ Motor Wire │ L298N Terminal │ Description │ │ ─────────────┼────────────────┼────────────────────────────── │ │ Red │ OUT1 │ Forward terminal │ │ Black │ OUT2 │ Backward terminal │ │ │ │ Specifications: 6V, 200RPM, Metal gears, 0.5kg torque │ │ Wheel Attachment: Standard motor shaft coupling │ │ Direction: Faces downward, wheel mounted vertically │ │ Mount Position: Front-left of chassis │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─ DC GEAR MOTOR #2 (RIGHT WHEEL) ─────────────────────────────────────────────┐ │ │ │ Motor Wire │ L298N Terminal │ Description │ │ ─────────────┼────────────────┼────────────────────────────── │ │ Red │ OUT3 │ Forward terminal │ │ Black │ OUT4 │ Backward terminal │ │ │ │ Specifications: 6V, 200RPM, Metal gears, 0.5kg torque │ │ Wheel Attachment: Standard motor shaft coupling │ │ Direction: Faces downward, wheel mounted vertically │ │ Mount Position: Front-right of chassis (mirror of Motor 1) │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─ DC GEAR MOTOR #3 (REAR/CASTER) ─────────────────────────────────────────────┐ │ │ │ Configuration: Optional 3rd motor or use as servo motor for backup power │ │ │ │ Option A - Third Drive Motor: │ │ - Wired directly to L298N OR through separate relay │ │ - Provides additional drive force for heavier loads │ │ - Mount at rear center position │ │ │ │ Option B - Servo Motor Backup: │ │ - Wired to Arduino Pin 12 through motor driver │ │ - Powers servo motor independently if main servo fails │ │ - Requires additional relay module (OPTIONAL) │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─ BATTERY PACK (7.4V Lithium or 6x AA) ───────────────────────────────────────┐ │ │ │ Battery (+) │ → L298N +12V input │ │ Battery (-) │ → L298N GND & Arduino GND (Common Ground - CRITICAL) │ │ │ │ Type: 2S Lithium (7.4V) or 6x AA cells (9V) │ │ Capacity: 1500mAh minimum for 2-3 hour runtime │ │ Connector: JST XT60 or Tamiya connector with ON/OFF switch │ │ Protection: Connect through 5A inline fuse for safety │ │ Mounting: Centered on chassis bottom using Velcro or strap │ └──────────────────────────────────────────────────────────────────────────────┘ ╔════════════════════════════════════════════════════════════════════════════╗ ║ BREADBOARD LAYOUT GUIDE ║ ╚════════════════════════════════════════════════════════════════════════════╝ POWER DISTRIBUTION RAILS: Top Red Rail (+5V from Arduino) ──→ All sensor VCC connections Top Black Rail (GND) ──→ All sensor GND connections Bottom Red Rail (Not used) ──→ Keep empty for safety Bottom Black Rail (Common GND) ──→ Battery GND connection point SIGNAL CONNECTIONS: Column A-B: HC-SR04 connections Column C-D: Line sensor connections Column E-F: Servo signal routing (if using breadboard) Column G-H: L298N control lines Column I-J: Reserved for future expansions ╔════════════════════════════════════════════════════════════════════════════╗ ║ COMMON WIRING MISTAKES & FIXES ║ ╚════════════════════════════════════════════════════════════════════════════╝ PROBLEM 1: Motors don't move Causes: • Battery not connected properly • Wrong pins used for motor driver inputs • Motor driver GND not connected to battery GND Solution: • Verify battery voltage with multimeter (should be 7-8V) • Check pin numbers in code match physical connections • Connect all GND points together with jumper wire PROBLEM 2: Servo jitters or doesn't respond Causes: • Power supply insufficient (servo draws up to 200mA) • Signal wire connected to wrong pin • Using Arduino 5V for servo power with heavy load Solution: • Add separate 5V power supply for servo • Verify orange signal wire on correct PWM pin • Add 100μF capacitor across servo power pins PROBLEM 3: Ultrasonic sensor gives wrong distances Causes: • TRIG and ECHO pins reversed • Sensor too close to obstacles • Interference from other devices Solution: • Double-check TRIG on Pin 7, ECHO on Pin 8 • Test sensor at least 20cm from objects • Keep sensor away from WiFi router PROBLEM 4: Line sensors don't detect line Causes: • Sensors not adjusted for ground color • Mounted too high or too low • Wrong analog pins used Solution: • Adjust sensor potentiometers with screwdriver • Mount exactly 1.5-2cm from ground surface • Verify output on A0 and A1 in serial monitor PROBLEM 5: Robot spins instead of moving forward Causes: • Motors wired with opposite polarities • IN1/IN2 or IN3/IN4 wires reversed Solution: • Swap motor terminal connections • Or reverse digital logic in code (swap HIGH/LOW) ╔════════════════════════════════════════════════════════════════════════════╗ ║ HARDWARE TEST PROCEDURES ║ ╚════════════════════════════════════════════════════════════════════════════╝ TEST 1: Motor Driver & Motors 1. Disconnect motors from L298N 2. Connect multimeter between OUT1 and OUT2 3. Send forward command from Arduino: OUT1 = +7.4V, OUT2 = 0V ✓ 4. Send reverse command: OUT1 = 0V, OUT2 = +7.4V ✓ 5. Reconnect motors and verify rotation direction TEST 2: Servo Motor 1. Upload servo test code 2. Servo should sweep 0° → 90° → 180° → 90° → 0° 3. Measure power consumption (should be <200mA) 4. Verify smooth operation without grinding noise TEST 3: Ultrasonic Sensor 1. Open Serial Monitor (9600 baud) 2. Place hand at various distances from sensor 3. Distance readings should change smoothly (0-400cm) 4. At close range (<5cm): should show stable low values TEST 4: Line Sensors 1. Place robot on white surface 2. Note analog values on Serial Monitor (A0 and A1) 3. Place on black line 4. Values should change significantly (100+ point difference) 5. Adjust potentiometers if difference is small TEST 5: Full System Integration 1. Load main code into Arduino 2. Keep robot in air (no contact with ground) 3. Activate line-following mode 4. Motors should run at consistent speed 5. Servo should scan continuously 6. Place robot on line 7. Robot should follow line smoothly ═══════════════════════════════════════════════════════════════════════════════ END OF WIRING REFERENCE GUIDE ═══════════════════════════════════════════════════════════════════════════════