Let's Make Robots!

rumble bee?

roll around and chase the cats

well since i put my other prototype on the side, i have decided to build my little rumble bee? its a $20 USD RC car from New Bright (cheap generic brand), which was suprisingly moduler constuction, i didng have to break any plastic or destroy the RF reciever which i may use in another project. so far it will go forward till it sees something that is 15 inches away, then back up,

still working on the turning, it seems that the gears are sliping when trying to turn so i may have to fasion a new turing system, so far i really like the ping sensor, because of how easy it was to get it to work with the arduino in less then 10 mins....i also decided to go with the ladyadas Motor sheild for ease of use, later on i will build more H bridges based on her designfor other projects,

i am still palning on adding headlights back up lights and turn signals. i am also planning on making a motion tracker on top of the bed 

more to come when i get the steering corrected and some better video with better light

 

my sample cod so far, i will be using my own custom header file soon enough to stream line the code but for the moment i will use the AFmotor.h header so far the code after it compiles takes 4.5kb

 #include <AFMotor.h>

AF_DCMotor motor(4, MOTOR12_64KHZ);
AF_DCMotor turn(2, MOTOR12_64KHZ);
int pingPin = 9;

void setup()
{
  Serial.begin(9600);
  motor.setSpeed(200);
  turn.setSpeed(0);
}

void loop()
{
  long duration, inches, cm;

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // We give a short LOW pulse beforehand to ensure a clean HIGH pulse.
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);

  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  // convert the time into a distance
  inches = microsecondsToInches(duration);
 


  delay(100);
 if (inches > 15) {
 
  motor.run(FORWARD);
  turn.run(RELEASE);
 }
 else {
    motor.run(BACKWARD);
    turn.run(BACKWARD);
    delay(400);
   
 }
}

long microsecondsToInches(long microseconds)
{
  // According to Parallax's datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance travelled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
  return microseconds / 74 / 2;
}

DSCN0082.JPG

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
You may have interest in this: Programming 3-point turns
i am deffinetly going to use that as a base for my turning and getting out of bad corners

That thing keeps running into shit! lol I give it a 5 for effort. j/k I do give it a 5 though. You just need some motor control and you will be good!

 

good job man!

 

:P

i have motor control but i dont have any restraint when it comes to fast moving toys ...the faster the better

i dont have any restraint when it comes to fast moving toys ...the faster the bettet

You don't say !

Neat toy though

Mike

I think it'll need more than 15inches at that speed.

out of control is right not even at top pwm (200/255),  i did a few tests at 30 inches, in a good straight run it will still hit the wall but not so hard anymore, i may have to tweak the code to try and turn before 30 inches, i have about 108 inches before it willl detect an object infront of it, i will also have to see how much room im goingt ot need to do a U-turn before it hits the object at that speed, well back to coding some stuff for work again....:(

 

For sharper turns, do powerslides like Frits does with his wall racers. They're also pretty fast and yet they miss the walls and each other beautifully.