Project #1 - object avoiding robot that's afraid of the dark

Hi,

 

This is my first project, a basic object avoiding robot based on the Start Here tutorial, but using Arduino. 

It uses an IR sensor to detect objects and decides which way is best to go, when it goes somewhere dark it will turn around.

I've made some changes to the code and the build of the robot, changed the build to make it a little bit tidier, but also needed to make it a bit easier for the robot to turn. Main reason to change the build though was that everything was stuck together using foamtape, which was fine, but this included the arduino. I'm planning to use the arduino on my next project, but still want to be able to easily switch it back to this bot, so have made it sit in a little box so it's easier for me to swap it round.

My (inefficient) code is attached, and list of components below:

  • Small Servo (9g) - SparkFun
  • Arduino Uno R3
  • AdaFruit motorshield for Arduino
  • 120:1 Gearmotor (x2)
  • 2x wheels (bottom of coke-cans)
  • Infrared Ranger (GP2Y0A21)
  • 1x 9v battery (to power Arduino)
  • 4x 1.2v 2900mAh NiMh AA batteries (to power motorshield)
  • A low resistance LDR
  • A lot of wires and an on/off switch

 

Current problems/Next steps:

- One of the motors tends to spin faster than the other, I'm trying to correct this through the code, but want to find out whether there is a hardware or wiring solution to this issue as well. 

-- Still correcting this in the code, which seems to work well now

- The distance returned by the IR sensor is not in a specific unit of measurement, I'd like to correct this to measure cm's, but am not sure how the voltage that goes through is different from when the robot is connected to my pc via USB versus when it's driving around autonomously. 

-- Drew up the graph of the distances the IR measures and their metric equivalents, so I at least now know that the robot will change direction when something comes in closer than 15 centimeters 

- The 9v battery powering the Arduino board only has about 15minutes of good life in it, not sure if this is something to do with the nature of the battery, Arduino, or my code. 

-- Soo, none of those! Based on the comments I'm blaming my servo, but have also got a new rechargable 9v which seems to last a while longer

- Planning to add some tactile push button switches to detect when the robot drives into something, just waiting for these to come through in the post now...

-- Am actually not going to bother as the LDR is pretty much fulfilling this function now

 

So I'm basically considering this project to be done now (I know it is actually not completely done and there's lots of other things I want to try to do with it, but I also want to move on to a new walker-type robot project, I'll put a link in here once I've decided what it's going to be and do and stuff. 

 

 

 

Navigate around avoiding obstacles via IR, and is "afraid of the dark", moves away from dark places using an LDR

  • Control method: autonomous
  • CPU: Arduino Uno R3
  • Programming language: Arduino Processing
  • Target environment: indoor

This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/project-1-object-avoiding-robot-thats-afraid-of-the-dark

Re: resolve IR to cm

Have you seen the graph that shows the response of your Sharp sensor? It is a logarithmic curve and won’t be easy to move that from numbers to distances.

Are those wheels made from

Are those wheels made from beverage cans? Now that’s how to recycle!

Nice combination of behaviors. 

Re: resolve IR to cm

Ah thanks, have been having a read of these http://luckylarry.co.uk/arduino-projects/arduino-using-a-sharp-ir-sensor-for-distance-calculation/ and http://www.societyofrobots.com/sensors_sharpirrange.shtml. Going to have a closer read of these this weekend to see if there’s a way to get a more or less accurate conversion, but looks a whole lot trickier than I was hoping for! 

Re: Love the wheels

Haha, cheers, the wheels came about due to sheer desperation. I had the whole thing built and programmed, but no wheels that would fit. It was one of those beautiful moments where I decided to have a drink and leave it all for another time, but then realised the can I was drinking from was the solution to my problem. I ended up drinking a lot of coke that day. 

Thanks for the comments on the battery, great to know Arduino converts my 9v back into 5v (I am very new to all this!), and will have a think about how I can reduce the power used by the servo (it’s constantly turning (1degree at a time, basically using the servo testing code from arduino.cc), but I’m only using input data from the sharp sensor at 3 points). I’m also not sure I fully understand how the battery supply to the arduino and the motor shield works, as the arduino seems to provide the motor shield with some power, to the servo for example, but the motors only appear to kick in when I plug in the additional pack of batteries. 

Re: Are those wheels made from

Yes! And using a bit of the side of the can to support the back of robot, which is also a cradle for the 9v battery…now looking to see if I can wrap the whole thing in a can…

Your arduino

has a 5v regulator that converts 7v(?) to 12v into 5v by way of converting the excess power required into heat. Your arduino requires 5v for its logic as do the inputs for the chip/s on your motor shield. The 5v that comes from the reuglator on the arduino is also fed to the motor shield for the logic chips that are on it. Look up the L293 or the 754410 quad half h-bridge chips. Their pinouts are the same and their function is the same. It might help you understand some things about your robot.

Re:

Cool, thanks, have been having a read and feel like I’m mostly up to speed now with the logic of the chips, just not entirely sure where the actual excess voltage goes? I can see there are two heatsink pins on the chips but not sure what these would be connected to? or where the heat goes? Should I be including a physical heatsink somewhere to avoid overheating, or won’t these voltages generate enough heat for that? Sorry, that’s a lot of questionmarks!