Let's Make Robots!

RC Car to robot

Navigates around the room using the PING sensor to look out in front of it. as soon as an object gets within 12 inches it backs up and turns left

Hello guys! My name is CreativeCorpse and this is my very first "robot" project. I know that there are probably 5000 diffrent versions of this same exact robot but i dont care...this one is mine haha. Basically i just used a RC car that i found in my niece's box of old toys and took the board out and replaced it with my Arduino Uno r3 with the motor sheild and then ran the motor wires into the sheild and wallah!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

We built a similar project.  However, we installed an Android device onto a RC car and used an IOIO board instead to control it autonomously. Here is the preliminary result:

http://youtu.be/vkvkfcqEUkk

I can understand posting in one or two threads where your robot has things in common with the robot page but 12 threads is crazy and possibly spam. Knock it off!

You're ruining what could have been a good reputation.

Not spam, Duane.  My work is authentic.  Just trying to connect with people who are working on similar projects.

One person's "connecting" is another person's spam. IMO, spam is when someone trying to "connect" sends out a bunch of identical messages.

How about making a page for your robot? I don't object to you or your robot but I don't think the way you've been posting is appropriate.

In stead of a bunch of identical posts about your robot on other people's robot pages, I'd much rather see a page about how you made and programmed your robot. Then you could get your message out from one location. IMO, you'd also be taken more seriously by fellow LRMians.

yours, I now see something else that should be mentioned. The L298 motor driver chip is seriously inefficient when it comes to pushing power it is fed to the motors.

**https://www.sparkfun.com/datasheets/Robotics/L298_H_Bridge.pdf The bottom of page 3 mentions total drop. Notice 1.8v min to 3.2v max for 1A and up to 4.9v max for 2A. I am pretty sure this is the ~2v drop I have read about that is expected when using this driver.

ive actually been having issues with a voltage drop with this sheild. its running fine but it seems to draw more power out of the channel B then A. im going to hook up a multimeter and test it out...ive also been wroking with obstacle avoidance and i cant seem to get the board to compare the distances...heres the code if you wanna take a look

 

#include<Servo.h>

const int pingPin = 7;

const int dangerThresh = 12;

int leftDistance, rightDistance;

Servo panMotor;

long duration;

 

 

void setup() {

 

  pinMode(12, OUTPUT);

  pinMode(13, OUTPUT);

 

  pinMode(9, OUTPUT);

  pinMode(8, OUTPUT);

 

  digitalWrite(9, LOW);

  digitalWrite(8, HIGH);

 

  digitalWrite(12, HIGH);

 

  analogWrite(3, 175);

 

  panMotor.attach(11);

  panMotor.write(90);

}

 

 

 

void loop() {

  int distanceFwd = ping();

  if(distanceFwd > dangerThresh) {

    digitalWrite(12, HIGH);

    digitalWrite(9, LOW);

    analogWrite(3, 175);

  }

 

  else {

    panMotor.write(0);

    delay(500);

    rightDistance = ping();

    delay(500);

    panMotor.write(160);

    delay(700);

    leftDistance = ping();

    delay(500);

    panMotor.write(90);

    delay(100);

    compareDistance();

  }

}

 

void compareDistance() {

  if(leftDistance > rightDistance) {

    digitalWrite(8, LOW);

    digitalWrite(13, HIGH);

    analogWrite(11, 255);

    delay(500);

  }

 

  else if(rightDistance > leftDistance) {

    digitalWrite(8, LOW);

    digitalWrite(13, LOW);

    analogWrite(11, 255);

    delay(500);

  }

  else {

    digitalWrite(12, HIGH);

    digitalWrite(9, LOW);

    analogWrite(3, 175);

  }

}

 

long ping() {

  pinMode(pingPin, OUTPUT);

  digitalWrite(pingPin, LOW);

  delayMicroseconds(2);

  digitalWrite(pingPin, HIGH);

  delayMicroseconds(5);

  digitalWrite(pingPin, LOW);

 

  pinMode(pingPin, INPUT);

  duration = pulseIn(pingPin, HIGH);

 

  return duration / 29 / 2;

 }

http://pastebin.com/uQvsdDke

See if that works and maybe makes more sense. You could replace the const int w/ const byte, or, #define and then lose the = and the ; . Your call.

you have so many magic numbers floating around. Where do pins 3, 11, 8, 9, 12, and 13 connect to? Are 3 and 11 really PWM?

i guess i forgot to mention that i am using a motor sheild..sorry bout that.

here are the pins, there functions, and the respective numbers

pin 12 = channel A, or the drive motor

pin 13= channel b, or the turn motor

pin 8= channel a brake

pin 9= channel b brake

and yes you are correct...pins 3 and 11 are the PWM

Okay here is the code that i wrote for this bot...its very basic. for some reason it seems as if the sensor is not cooperating with the motors...any ideas?

 

const int pingPin = 7;

 

void setup() {

  pinMode(12, OUTPUT);

  pinMode(13, OUTPUT);

 

  pinMode(9, OUTPUT);

  pinMode(8, OUTPUT);

 

  digitalWrite(9, LOW);

  digitalWrite(8, HIGH);

 

  analogWrite(3, 175);

 

  digitalWrite(12, HIGH);

}

 

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);

 

  if(inches < 12){

    digitalWrite(9, HIGH);

    delay(100);

 

    digitalWrite(8, LOW);

    digitalWrite(13, LOW);

    analogWrite(11, 255);

 

    digitalWrite(9, LOW);

    digitalWrite(12, LOW);

    analogWrite(3, 175);

    delay(2000);

 

    digitalWrite(8, HIGH);

    digitalWrite(9, HIGH);

  }

 

  else{

    digitalWrite(12, HIGH);

    digitalWrite(9, LOW);

    analogWrite(3, 175);

  }

 

  delay(100);

}

 

long microsecondsToInches(long microseconds)

{

  return microseconds / 74 / 2;

}