Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Simple Obstacle Avoidance Robot

19 Aug 2016 1  
This project is about a simple obstacle avoiding robot using Intel® Edison module. Robotics is an exciting and fun hobby that has become very affordable in recent years.

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.

Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.

Summary

This project is about a simple obstacle avoiding robot using Intel® Edison module. Robotics is an exciting and fun hobby that has become very affordable in recent years. Lets do it.

Parts List

  • Cardboard.
  • Battery.
  • Ball bearing for front roller.
  • 2 servo motors.
  • 2 matching wheels.
  • Intel Edison with Arduino breakout board.
  • Breadboard.
  • Ultrasonic Range sensor – HC-SR04.
  • Capacitors (220uF).
  • Jumper Wires,rubber bands,Glues, etc…

<img height="933px" src="1119422/img_0667.jpg" width="700px" />

Steps To Be Followed

Step 1: Chassis

We chose a simple cardboard based chassis with the servos attached to it with the help of rubber bands. Make it convenient for your use. The above choices work as long as your rover is roving over smooth surfaces. Attach the front ball bearing in front of the cardboard.

Set front wheel ball bearing:<img height="472px" src="1119422/img_0729.jpg" width="629px" />

Attach single servo motor:

<img height="832px" src="1119422/img_0726.jpg" width="624px" />

Attach both servo motors:

<img height="851px" src="1119422/img_0671.jpg" width="638px" />

our chassis is ready.

Step 2: Arduino Board With Intel Edison

Configure your arduino board with intel edison. Look at this link to configure (https://software.intel.com/en-us/iot/library/edison-getting-started). Make sure your serial communiction and port are fixed. Check out your arduino board with intel edison by loading a simple program to your board.

<img height="831px" src="1119422/img_0656.jpg" width="623px" />

Let's check out our board with simple blinking led.

<img height="525px" src="1119422/img_0674.jpg" width="700px" />

Step 3: Battery And Board

Mount this battery using battery holder and board then later secure it to the chassis using rubber bands – surprisingly this works pretty well (remember this is planned on using this on smooth surfaces only – adjust the attach according to your plans). We have to use 6 AA battery holder in order to hold six batteries (based on motors you can use your batteries).

Step 4: Arduino Pins

These are the ARDUINO PINS which it is attached for this project. You can set the pins on your own.

Ultrasonic Range Sensor (HC-SR04) ECHO 9
Ultrasonic Range Sensor (HC-SR04) TRIG 10
Servo signal (left) 5
Servo signal (right) 6

Step 5: Ultrasonic Range Sensor (HC-SR04)

First of all check Ultrasonic Range Sensor (HC-SR04) by using a simple arduino code. Connect the ultra sonic sensor using some jumper wires.

<img height="525px" src="1119422/img_0723.jpg" width="700px" />

Here we have checked our ultra sonic sensor using simple program.

<img height="525px" src="1119422/img_0725.jpg" width="700px" />

By checking in serial port of arduino uno we can have a clear thought that it is working. Ultrasonic sensor shows the distance of the object in front of it. Here in our code distance is calculated in centimeter.

Below image shows the distance calculated by ultrasonic sensor in serial port (cm).

<img height="359px" src="1119422/file2.jpg" width="640px" />

Step 6: Servo Motor Connections

The wiring needed for connecting the servo cable — 3 pin connection coming out from the servo – red (vcc), black(ground) and in my case yellow(signal). The picture (Servo wiring 1) shows the 220uF capacitor connected between vcc/ground – this is needed for each servo in order to avoid the brownout issues. Since we are using the same battery source to power the servos and the board. on sudden rover turn of directions, there can be spikes of current draw which can cause the board to recycle if we don’t provide a sizeable capacitor (220uF works just fine in our case). The pictures show wiring for 1 servo without the servo cable attached (Servo wiring 1) with the servo cable attached (Servo wiring 2) and then both the servo cables attached.

<img height="933px" src="1119422/img_0731.jpg" width="700px" />

Step 7: Coding And Testing

Apply the code and test it.

#include<Servo.h>
#define trigpin 10 // Trigger pin
#define echopin 9 // echo pin

Servo servoLeft;
Servo servoRight;

int forward = 180;
int backward = 0;

void setup() {
Serial.begin(9600);
servoLeft.attach(5);
servoRight.attach(6);

pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);

}

void loop ()
{
int duration, distance;
servoRight.write(forward);
servoLeft.write(forward);

digitalWrite(trigpin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigpin, LOW);
duration = pulseIn(echopin, HIGH);

distance = ( duration / 2) / 29.1;

delay(1000);
if (distance >= 10)
{
Serial.print(distance);
Serial.println(&rdquo; cm&rdquo;);
}
else
{
Serial.println(&ldquo;danger&rdquo;);
servoLeft.write(90);
servoRight.write(90);
delay(1000);

servoLeft.write(backward);
servoRight.write(forward);
delay(5000);
servoLeft.write(forward);
servoRight.write(forward);

}

}

Now we have done. Here is our simple obstacle avoiding robot using intel edison.

<img height="933px" src="1119422/img_0651.jpg" width="700px" />

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here