5-in-1 Arduino Robot | Follow Me | Line Following | Sumo | Drawing | Obstacle Avoiding

In this tutorial, we’ll build a 5-in-1 multifunctional Arduino robot that can switch between five autonomous modes — Follow Me, Line Following, Sumo, Drawing, and Obstacle Avoidance.

Powered by an ATmega328P-L293D driver board, this robot is compact, easy to solder, and versatile. The board integrates a motor driver (L293D) directly with the ATmega328P microcontroller, eliminating the need for separate motor shields or messy jumper connections.

With the right sensors and control logic, this project gives you a complete robotic platform that’s ideal for students, makers, and hobbyists who want to explore multiple robotics behaviors using one board.

Features of the Robot Control Board

This custom PCB combines:

  • ATmega328P-PU (with bootloader) – the same chip used on Arduino Uno
  • L293D Motor Driver – drives two DC motors directly from the board
  • CH340G USB Interface – allows direct programming without external programmer
  • Onboard Power Regulation – supports both 5V and 12V supplies
  • Pin Headers for Sensors – ready-to-connect for Ultrasonic (HC-SR04) and IR sensors

It’s a self-contained robot controller, meaning you can easily program it through the Arduino IDE just like a standard Uno.

Components Required

ComponentQuantityNotes
ATmega328P-PU with Bootloader1Main MCU
L293D Motor Driver IC1Dual DC motor control
HC-SR04 Ultrasonic Sensor1Distance measurement
IR Infrared Sensor Module1Line tracking or obstacle detection
6V 200RPM Mini Metal Gear Motor2Robot movement
Type-B USB Socket1Programming via USB
L7805 Voltage Regulator15V power supply
100µF, 470nF, 10nF, 22pF CapacitorsAs listedFor decoupling and filtering
Resistors 10KΩ / 1KΩ / 220ΩAs listedBiasing and LED control
LED (Indicator)1Power or status indication
12/16 MHz Crystal2Clock for ATmega and USB
Power Jack Socket1External power input
2-Pin Terminal Blocks2For Motor A and B outputs
7.4V LiPo or 9V Battery1Power source
Male Pin HeadersSeveralSensor and motor connections

PCB + 3D files available here:
👉 PCBWay Project Link

Pin Configuration Overview

🔹 Motor A Connections

SignalArduino Pin
Motor A1D2
Motor A2D4
Motor A Enable (PWM)D3

🔹 Motor B Connections

SignalArduino Pin
Motor B1D10
Motor B2D11
Motor B Enable (PWM)D9

🔹 HC-SR04 Ultrasonic Sensor

PinArduino Pin
VCC+5V
GNDGND
TrigD6
EchoD5

🔹 IR Sensor

PinArduino Pin
VCC+5V
GNDGND
SignalD12 or D13

Operating Modes

The board supports five robot modes, each programmed separately.
Each .ino file defines unique behaviors that can be uploaded via Arduino IDE.

ModeDescription
1. Follow Me ModeUses HC-SR04 to follow an object in front by measuring distance.
2. Line Follower ModeUses IR sensors to follow a black or white line on a surface.
3. Sumo ModeRobot pushes the opponent out of a ring using IR and distance sensors.
4. Obstacle Avoidance ModeDetects obstacles and turns to avoid collisions.
5. Drawing ModeUses a servo-controlled pen to draw shapes as it moves.

Step-by-Step Setup Guide

Step 1: Assemble the PCB

Solder all DIP components carefully according to the silkscreen.
Start with small components (resistors, capacitors) → then IC sockets → then large components (USB, power jack, terminal blocks).

Step 2: Install the ATmega328P Bootloader

Use an existing Arduino as ISP to burn the bootloader if needed.
Once flashed, you can program it directly using the CH340G USB port.

Step 3: Connect Motors & Sensors

Refer to the diagrams above.
Ensure motor polarity and sensor power lines are correct.

Step 4: Upload Each Mode Code

Use Arduino IDE to open and upload each mode:

  • Drawing_Mode.ino
  • Follow_Me_Mode.ino
  • Line_Follower_Mode.ino
  • Obstacle_Avoiding_Mode.ino
  • Sumo_Mode.ino

You can find all source codes here: 👉 PCBWay Project Link

Example: Follow Me Mode

Here’s a simplified and improved version of the Follow Me mode:

#include <NewPing.h>

#define TRIG_PIN 6
#define ECHO_PIN 5
#define MAX_DISTANCE 200

#define ENA 3
#define IN1 2
#define IN2 4
#define ENB 9
#define IN3 10
#define IN4 11

NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE);

void setup() {
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  pinMode(ENA, OUTPUT);
  pinMode(ENB, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  delay(50);
  int distance = sonar.ping_cm();
  Serial.print("Distance: ");
  Serial.println(distance);

  if (distance > 0 && distance < 15) stopMotors();
  else if (distance >= 15 && distance < 30) forward();
  else if (distance >= 30) stopMotors();
  else stopMotors();
}

void forward() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  analogWrite(ENA, 200);
  analogWrite(ENB, 200);
}

void stopMotors() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

Code Improvements Applied

✅ Replaced manual timing with NewPing library for better sensor precision.
✅ Added adjustable PWM speed control.
✅ Improved logic for smoother motion transitions.
✅ Simplified pin definitions and direction logic.
✅ Structured comments for beginners.

BOM (Bill of Materials)

The PCB BOM file includes every component with manufacturer part numbers for easy ordering — suitable for fabrication services like PCBWay.

IDComponentQuantityManufacturer
1ATmega328P-PU1Microchip
2L293D1STMicroelectronics
3CH340G1WCH
4L7805ABV1STMicroelectronics
5Capacitors (10µF, 100µF, 22pF, etc.)ValuePro / Dersong
6Crystals (12MHz, 16MHz)2YXC
7Terminal Blocks2DIBO
8LED (XL-502SURD)1XingLight

Conclusion

The 5-in-1 Arduino Robot is an excellent modular platform to explore robotics with ATmega328P and L293D integration.
With a single board and a few sensors, you can experiment with multiple control algorithms — from simple line following to interactive “Follow Me” behavior.

It’s a perfect learning platform for:

  • Robotics students
  • STEM education
  • Hobby robot enthusiasts

3D robotic projects arduino projects Arduino Robot ATmega328P HC-SR04 IR Sensor L293D Line Follower pcb projects PCBWay Project Sumo Robot

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir