Introduction: MAZE Robot With Arduino

About: I am an electronic hobbyist on Arduino, Photon, Raspberry Pi and common electronics.A passionate cook.Any assistance in electronics and web development feel free to contact me at

Hey, guys!! I'm Sridhar Janardhan back another instructable this time in the category of robotics.Amazing isn't it??So the robot which we are going to design is MAZE robot or obstacle avoiding robot this can be used as a surveilance system in your domestic place or just for a fun activity to learn the basics of robotics.So let's get started in constructing it.

If you guys have missed my previous instructable please click the text here.

Step 1: Electronics Required:

The electronics required for this Instructable are:

  • Arduino Uno
  • Ultrasonic sensor
  • @ x DC motor
  • L293d motor driver
  • 9v battery
  • caster ball
  • motor wheels

So now let's get into the building of a circuit.

Step 2: Fixing of Motors and Motor Drivers to the Chassis:

Arduino alone can't drive the motors as it consumes more energy, For this purpose, a specially designed IC like l293d or l298N is used.I have used L293d because it can maximum upto 5V motor whereas the l298N will drive the motor upto 12volt rating.So choose the driver accordingly.

follow the below connection carefully:

  • Fix the motor in the slot of chassis.
  • Fix the wheels in the shaft of the DC motor.
  • Now place the Motor driver above or below the chassis surface.
  • The 1st input(IN1)is given to Arduino pin 4 and 5.
  • The 2nd input(IN2)is given to Arduino pin 2 and 3.

Here the proper chassis is finished, Let's move on connecting the eye and brain of the chassis.

Step 3: Fixing Ultrasonic Sensor:

I have explained what is an Ultrasonic sensor in my previous Instructables.I assume that you went through my previous Instructables to have a good knowledge about how an ultrasonic sensor works.Now let's connect it.

The connection is as follow:

  • VCC pin to 5V off Arduino pin
  • GND pin to GND pin of Arduino
  • TRIG pin to Digital pin 9 of Arduino
  • ECHO pin to Digital pin 8 of Arduino.

So the hardware interfacing is done now let's start the coding for the microcontroller.

Step 4: The Code for Microcontroller:

#define echopin 8 // echo pin

#define trigpin 9 // Trigger pin

int maximumRange = 30;

long duration, distance;

void setup() {

Serial.begin (9600);

pinMode (trigpin, OUTPUT);

pinMode (echopin, INPUT );

pinMode (2, OUTPUT);

pinMode (3, OUTPUT);

pinMode (4, OUTPUT);

pinMode (5, OUTPUT); } void loop () {






duration=pulseIn (echopin,HIGH);

distance= duration/58.2;

delay (50);



if (distance >= 30 ){





delay (200); }

else if (distance >=15 && distance <= 25) {

digitalWrite (2,HIGH);

digitalWrite (3,LOW);

digitalWrite (4,LOW);

digitalWrite (5,LOW);

delay (1000); }

else if (distance < 15){

digitalWrite (2, LOW);

digitalWrite (3, HIGH);

digitalWrite (4, LOW);

digitalWrite (5, HIGH);

delay (1000);

digitalWrite (2,LOW);

digitalWrite (3,LOW);

digitalWrite (4,HIGH);

digitalWrite (5,LOW);

delay (1000); }


Step 5: Assistance:

need assistance??, any kind of electronics projects kindly leave a comment or send your project abstract to and follow to be updated on my latest Instructable.

Thank you.

Makerspace Contest 2017

Participated in the
Makerspace Contest 2017