Let's Make Robots!

This is just a prototype for my code. I have it right now avoid object about 2 1/2 inches away. This is my first robot and first time actually really programming so its not that great. I still have a lot of work to do on the code. I made this robot out of popsicle sticks, dowel rods, rubber bands, super glue, and hot glue. Took me a while just to figure out how I wanted to do it. First I started with some popsicle sticks to get the servos attached together. I'm using Airtronics 94102z servos. I modify them myself which wasn't a pain at all. I actually enjoyed it lol.Photobucket

Photobucket

Then what I originally was going to do was give it four wheels.Photobucket

I had to change that for I ran into a few other problems like alot of drag.  So I turn it into a three wheeler. The back wheels I got from hobby store which were for airplanes. They are the Lite Flite Wheels and 3 1/4in, which they have really good tractions on them. The wheels I have in front are use for your main landing gears. I use it since I didn't really have to do anything to them but align it up in the middle and hot glue it underneath since it was already connect to a rod.

Photobucket

This is the top view, I know lots of wires and a bit of a mess. Actually the way I have it connect is just the 3 servos connected to the 4 AA batteries and I grounded the 3 servos, battery back, and the arduino together. I used a 9v battery to power the Sharp sensor and arudino. So I then grounded the Sharp sensor, 9v battery, and the board together. I figure thats how I was suppose to do it.

 

 

 

Photobucket

As you can see in this picture I have a few dowel rods forming a barrier around the servo. At first it wanted to slide a little to the back so I added two more dowel rods in front which fit right in the two holes. So I place a small piece of popsicle stick in front to make it stay in place. It worked out really good. Anything else you would like to see or I left out just let me know and I will post it.  I'm sorry about the bad video, but its the best I can do right now.

Photobucket

Comment viewing options

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

Nice Build - are they Foam type wheels .... looks like a smooth ride.

Bet it can climb from floor to carpet with those traction wheels.

Yep foam tires made for airplanes.  They have really good traction on them, sometime a little to good and if it miss a scan its start to climb up stuff.
OddBot's picture
Congratulations on your first robot!  :D
LOLGeek's picture
Great for your first robot... :)
sorry I'm a bit hard learning something new.  I don't know anything about break or case.  What I read break is to get out of a for loop but don't know about case.
voodoobot's picture

The break statement does the same thing with the switch/case structure.

You can use the switch/case which is kinda like an if statement. look here for info.

 like

case_number = 22 //this does case 22

switch(case_number) {

 case 22:

 do_this_stuff();

break; //this exits out of the structure.

case 33:

 do_other_stuff();

break;

case 44:

 do_stuff();

break;

default: //if it doesn't match anything, do this

default_stuff();

 }

voodoobot's picture

since you're using the values based on the angle that you are at and put that in an array you could do it slightly differently.

 

add a function that uses the current servo direction

void myservodir(int s_pos, int dist) {

 switch (s_pos)

case 20:

if dist < range;

{ left(); }

break;

 case x fill in the rest of the cases here

case 160:

 if dist < range;

{ right(); }

default:

do sometheing else

}

 

Add this call to your for loops maybe before you send out the serial data

change distance to a non array.

the call would be something like:

myservodir(myAngle, myDistance)

Having some issues with my code that doesn't seem to want to work right now.  Object on left it wait till the end of loop to react, object on the right wait till the beginning of the loop, and object infront wait till the beginning of loop.  Whats wrong???

 int i;
 
  if (last_sweep_right)  //last round we sweep to right?
 
  {
   last_sweep_right = 0;
   i=0;  // from left to right
 
  for (myAngle = 20; myAngle <= 160; myAngle+=10)
  {
    servoPulse(myservo, myAngle);
    delay(wait);
    distance[i++] = analogRead(0);  // read sensor in array
    Serial.println(analogRead(0));
  }

  }
else

{
  last_sweep_right = 1;
  i=14; // from right to left


  for (myAngle = 160; myAngle >= 20; myAngle-=10)
 
  {
    servoPulse(myservo, myAngle);
    delay(wait);
    distance[i--] = analogRead(0); // read sensor in array
    Serial.println(analogRead(0));
  }
}

ezekiel181's picture

Sorry I misunderstood before the reason for having the 2 different loops.

The array starts at 0, so distance[i++] might be skipping the first spot. But I can`t see anything really "wrong" with this, although I dont really understand the problem properly.

Can you post the code that does your direction decision making?

jklug80's picture
Very cool looking. I like the color.