Let's Make Robots!

Clean navigation using IR sensor

Anyone willing to give me a hand with this code please feel free to jump right in.

I have spent any hours trying to get this to work. I sure have gotten closer but the bot seems to get stuck n reverse for whatever reason. He will stay in reverse untill i bring my hand close to the sensor and then move it away very quickly.

He then continues forward. Sometimes it seems like he wants to turn toward the object he sees

Picaxe 28x1 with sharp GP2D12

I have made many changes to Fritsl's code, Some changes I understood and others I did not.

 

 

AttachmentSize
g_bot.bas722 bytes

Comment viewing options

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

Did you add a capacitor (soldered as close as possible to the sensor) to the sensor? It will help clean up any spikes in the supply.

What size cap and can you be more specific as to which wires I should solder it to?

Would that be red and black and should I add it right at the sensor?

A 10uF (10 microfarad) capacitor between Power and Ground, and attached directly to the sensor would be best. Be careful that polarity is correct (Ground to ground, power to power).

Here's a good article, may help you:

http://www.robotroom.com/DistanceSensor3.html

I dont have a 10 uf cap, will a 0.1uf work.

I cant profess to understand everything on that page.

The 2nd graph shows use with a 0.1uf capacitor, and shows a significantly reduced voltage spike from the sensor, and is much better than no capacitor.

Forget the cap, yo. This is a classic case of modifying else's code. You have a good ol' bug in your code.

Now, I say this with experience: It is a full-blown mess trying to modify other's code. It is so easy to miss one "twice-used" variable or a stray sub-routine. I have even actually tried to adapt the very code you are using and failed. 

My suggestion, and I know it sucks... You gotta write your own.

Keep the cap, helps remove voltage spikes.
Heck I dont understand enough yet to write my own
Well, it is partially working, which is better than not working :)