loading

It is a self obstacle avoiding robot. It uses two ping sensors for obstacle detection. It uses a Adafruit L293D Motor Shield to power four high torque 12volt motors. It also feawtures a Arduino UNO R3 as a microcontroller to control the complete robot.

Step 1: Materials Needed

The following materials are required in this project:

  • Arduino Uno R3 (1x)
  • L293d Motor Shield (1x)
  • Ping / Ultrasonic Sensor (2x)
  • 4 Wheel Drive Robot Chassis (Small) (1x)
  • Centre Shaft Economy series motors {100 RPM} (4x)
  • 70mm Diameter x 19mm Thick x 6mm Bore Wheel (4x)
  • Wires (As Required)

The following tools are required in this project:

  • Soldering Iron
  • Screwdriver
  • Black Tapes
  • Wire-cutter
  • Plywood (optional)
  • Aluminum Square Bar (optional)
  • Screws

Step 2: Prepare the Chassis

Now First of all prepare the chassis. Attach the four motors with the base using the nut wholes present on the base. Attach the wheels with the motors. Solder wires with the motors. Be careful in soldering as it may burn your skin.

Step 3: Prepare the Ultrasonic / Ping Sensor

Solder four wire with ping/ultrasonic sensor on the for heads on the sensor namely Vcc, Trig, Echo, GND.

Caution: Be very careful while soldering the wires with the pins present on the sensor. Don't put the soldering iron for much time in the sensor. Try to do the soldering in small amount of time. But be careful not to join two pins with one another. The circuit will got damage.

Repeat the same step with the Other Sensor

Step 4: Prepare the Arduino Board

Connect he Arduino Board with PC via USB cable.

"Please don't share this code online without the author's permission"

Load the following sketch on it using the official Arduino programming software:

/* Code Written by Pathikrit. I've explained the code in the grey comments. Change it by your wish. Please don't share this code on internet without the publisher's permission */
#include  //import your motor shield library
#define trigPin 2 // define the pins of your sensor
#define echoPin 13 
AF_DCMotor motor1(1,MOTOR12_64KHZ); // set up motors.
AF_DCMotor motor2(2, MOTOR12_64KHZ);
AF_DCMotor motor3(3,MOTOR12_1KHZ); // set up motors.
AF_DCMotor motor4(4, MOTOR12_1KHZ);
 
void setup() {
  Serial.begin(9600); // begin serial communitication  
  Serial.println("Motor test!");
   pinMode(trigPin, OUTPUT);// set the trig pin to output (Send sound waves)
  pinMode(echoPin, INPUT);// set the echo pin to input (recieve sound waves)
  motor1.setSpeed(175); //set the speed of the motors, between 0-255
motor2.setSpeed (175);
motor3.setSpeed (175);
motor4.setSpeed (175);
}
 
void loop() {
   long duration, distance; // start the scan
  digitalWrite(trigPin, LOW);  
  delayMicroseconds(3); // delays are required for a succesful sensor operation.
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); //this delay is required as well!
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;// convert the distance to centimeters.
  if (distance < 20)/*if there's an obstacle 5 centimers, ahead, do the following: */ {   
   Serial.println ("Close Obstacle detected!" );
Serial.println ("Obstacle Details:");
Serial.print ("Distance From Robot is " );
Serial.print ( distance);
Serial.print ( " CM!");// print out the distance in centimeters.
Serial.println (" The obstacle is declared a threat due to close distance. ");
Serial.println (" TURNING !");
   motor1.run(BACKWARD);  // Turn as long as there's an obstacle ahead.
    motor2.run (BACKWARD);
    motor3.run(FORWARD);  // Turn as long as there's an obstacle ahead.
    motor4.run (FORWARD);
}
  else {
   Serial.println ("No obstacle detected. going forward");
   delay (15);
   motor1.run(FORWARD); //if there's no obstacle ahead, Go Forward! 
    motor2.run(FORWARD);
  motor3.run(FORWARD); //if there's no obstacle ahead, Go Forward! 
    motor4.run(FORWARD);  
  }  
  
  

}

Step 5: Solder the Wires With the Motor Shield

Solder wires with the following pins present on the L293d Motor Shield:

  • Pin 2
  • Pin 13
  • Pin 5v
  • Pin GND

Be careful in soldering the pins. Don't solder with the wrong pins {IF DONE THE THE WHOLE PROJECT WILL CRASH}.

Step 6: Motor Shield With Arduino UNO R3

Attach the motor shield on the Arduino UNO board. Connect it fully so that no damage is done with the boards.

Step 7: Connect the Sensors

Connect the sensors with the following soldered pins on the motor shield:

Pin 2 on the Motor Shield board with the Trig pin on the sensor board {Connect both the sensors with one another by matching the pins same}.

Pin 13 on the Motor Shield board with the Echo Pin on the sensor board.

Pin 5v on the Motor Shied board with the Vcc Pin on the Sensor board.

Pin GND on the Motor Shield with the GND Pin on the Sensor board.

Step 8: Connect Motors & Shield

Connect the Motors with the Motor Shield using the M1, M2, M3, M4 pins present on the Shield as given in the above Diagram.

Step 9: Assemble Everthing in the Chassis

Assemble all the parts in the chassis as your wish. Make it look more attractive. Connect the external power Supply with a 12v Dc 2a adapter or a such power battery. Enjoy the Robot

That is a good project but you should have posted your original photos in the steps.
<p>Thanks for sharing your awesome robot! </p>

About This Instructable

6,270views

38favorites

License:

More by Pathikrit:Self Obstacle Avoiding Robot 
Add instructable to: