Introduction: Simple Robot

Picture of Simple Robot

I had a gh-311rt ultrasonic sensor which did not have a datasheet. So i ran it with a ping))) program. You can easily try it with the cheapest 3 pin sensor . No need to go after ping)))

Step 1: Get the Stuff

Picture of Get the Stuff

here is what you need.

1x Gh 311-rt sensor (if you have ping))) use it.If you have hc sr04 modulate the code) from here.

2x BO motors (75 rpm)

1x motor driver module. over here.(i used a motor driver if you want to reduce it use servomotors modified for 360)

1x Chassis set here (i scavenged one from one kit)

1x Arduino uno (it is awesome)

1x programming cable

wires

2x batteries (i suggest duracell enercell or one from radioshack)

croc clips

now begin

Step 2: Assembly

Picture of Assembly

start with the caster.

now mount the motors.

mount those gigantic nut like things as shown.

now mount the motor driver on the supposedly top plate (identified with more screw holes).

and the awesome arduino on the other side of the same plate.

Step 3: Motor Driver

Picture of Motor Driver

here are the connections.

motor1 + to the m1 output lead screw tab number 1

motor1 - t the m1 output lead

same are followed on the other side.

if the motors donot move in the wanted direction just change the leads on the arduino. On the arduino.!!!

Step 4: Arduino Connection

Picture of Arduino Connection

now connect the m1 enable + lead to pin 2 on the arduino and the - lead to pin 4.

then m2 enable + to pin 7 on arduino and - to pin 8 on the arduino.

Step 5: Ultrasonic

Picture of Ultrasonic

mount the ultrasonic sensor as shown ,on the bottom plate.

here are the connections,

vcc or + to 5v

gnd or - to gnd

output to pin 12 on arduino.

Step 6: Finishing Touch

Picture of Finishing Touch

get it together (chassis) leave a wire on the motor drivers power pins positioned behind and here is the program.

//this is a code for controlling a simple robot using an arduino and a motor driver.
//created by robobot3112

const int loopPeriod = 20;

unsigned long loopdelay = 0;

const int sensor = 12; // ARDUINO OUTPUT PIN FOR SENSOR INPUT/OUTPUT

const int p1 = 8; // ARDUINO OUTPUT PIN FOR MOTOR INPUTS

const int p2 = 7; // ARDUINO OUTPUT PIN FOR MOTOR INPUTS

const int p3 = 4; // ARDUINO OUTPUT PIN FOR MOTOR INPUTS

const int p4 = 2; // ARDUINO OUTPUT PIN FOR MOTOR INPUTS int ultraDistance;

int ultraDuration;

void setup()

{

Serial.begin(9600);

pinMode(p1 , OUTPUT);

pinMode(p2 , OUTPUT);

pinMode(p3 , OUTPUT);

pinMode(p4 , OUTPUT); }

void loop()

{

if(millis() - loopdelay >= loopPeriod)

{

readUltrasonicSensors();

motorstate();

loopdelay = millis();

}

}

void readUltrasonicSensors()

{

pinMode(sensor , OUTPUT);

digitalWrite(sensor , LOW);

delay(2);

digitalWrite(sensor , HIGH);

delayMicroseconds(10);

digitalWrite(sensor , LOW);

pinMode(sensor , INPUT);

ultraDuration = pulseIn(sensor , HIGH);

ultraDistance = (ultraDuration/2)/29;

}

void motorstate() // MOTOR CONTROL FUNCTION

{

if((ultraDistance > 15)||(ultraDistance < 0))

{

digitalWrite(p3 , HIGH);

digitalWrite(p1 , HIGH);

digitalWrite(p2 , LOW);

digitalWrite(p4 ,LOW); }

else

{

digitalWrite(p1 , HIGH);

digitalWrite(p2 , LOW);

digitalWrite(p3 , HIGH);

digitalWrite(p4 , LOW);

}

}

Step 7: Finished Is Your Robot

Picture of Finished Is Your Robot

let me hope your robot worked well.

if you face any problem let me know :)

the end

Step 8: Let There Be Lifeeeeee!

To power this beast you require 2 9v batteries (1 for motor driver and other for the Arduino).

Comments

Jose EduardoJ (author)2015-05-27

ey friend i have some problems with the gh-311 sensor, i use this code an it start giving me random numbers.

const int pingPin = 7;

void setup() {

Serial.begin(9600);

}

void loop()

{

long duration, inches, cm;

pinMode(pingPin, OUTPUT);

digitalWrite(pingPin, LOW);

delayMicroseconds(2);

digitalWrite(pingPin, HIGH);

delayMicroseconds(5);

digitalWrite(pingPin, LOW);

pinMode(pingPin, INPUT);

duration = pulseIn(pingPin, HIGH);

inches = microsecondsToInches(duration);

cm = microsecondsToCentimeters(duration);

Serial.print(inches);

Serial.print("in, ");

Serial.print(cm);

Serial.print("cm");

Serial.println();

delay(100);

}

long microsecondsToInches(long microseconds)

{

return microseconds / 74 / 2;

}

long microsecondsToCentimeters(long microseconds)

{

return microseconds / 29 / 2;

}

could you show the numbers a screenshot will help.

robobot3112 (author)2014-08-16

not quiet a kit i scavenged the chassis and used it. with the kit you get a fake arduino

it doesnt work so i made my own robot using the chassis to an advantage.

seamster (author)2014-08-15

Cool! Was this a kit?

About This Instructable

4,284views

32favorites

License:

Bio: The world is a Roller coaster, Im the operator.
More by robobot3112:Cheap Versatile Mini TricopterRace Spec 260 Class Fpv Racing Quadcopter Ultimate guide to building your multirotor frames cheap
Add instructable to: