How to keep pixace controlled robot from getting stuck?


I have built my first robot after advice of  LMR start here. So my robot is navigating with help of IR sensor and has those standard geared motors.

 I'm wondering if picaxe can read information from motors if the robot gets stuck. I guess motor makes some noise in such a situation?Can pushing against some obstacle with rubberwheels on harm picaxe?

I would be grateful for any piece of advice!


For Chris’ first suggestion …

on monitoring current, you should check .

thanks and more…

Thank you for helping!

Although monitoring current seems to be good option in long run i’ll try first combination of LDRs for close range warning system and some kind of encoder based on hall effect sensors.

I studied ways of calculating suitable resistor to divide voltage for analogue input. However I couldn’t find answer for some questions.

1. Can i actually use any resistor? is this only question of setting sensible range for a typical situation of your LDR or is it possible that too little or too high resistance in total (LDR and resistor) can cause damage for picaxe?

2. Could it be possible to have several LDR connected in series and to have one Vout for them?

3. I was planning to have one LDR measuring overall light intensity and some in front to detect obsctacles. Would it work if i connected “overall” LDR to ground and another to Vin? would this balace the changes in overall light intensity so that dangerlevel wouldn’t be achieved too easily when having dim overall light?

I think the configuration

I think the configuration below would work for a single LDR. Setting the resistor value close to the LDR’s value when in dim light should help it work OK in most lighting conditions. Be sure the resistor value isn’t too low, so that there is protection from 5V power to ground when the LDR value is close to zero in bright light.

I = V / R

So 1k ohm gives you 5mA at 5V, which should be safe. Use at least 1k for the resistor; 10k is even better. If your 5V supply is not clean/regulated, you might include a 1k ohm in series with the LDR as well.



I like the concept you introduce in question #3, where you balance the detection LDR with another LDR to sense the ambient lighting conditions. However, let's take a closer look:


Here you are creating a dangerous condition, where you can short your power to ground. No good!

However, your basic concept if valid. See below.


I have never tried this, but I think it will be safe and should work. Depending on your LDRs, you may have to play with the resistor values a bit. The bottom LDR would be pointed straight up to sense ambient light. The object detecting LDR will be placed in front of the robot, and will detect dark when it is blocked.


Another way to sense ambient light with the first setup is to take a quick analog reading when your robot starts up. As long as the LDR is not blocked during start up, you will now have an ambient light reading to compare against.

Yet one more idea is to install an LED mounted next to the detection LDR. Insert the LDR in a piece of shrink wrap, so it can only see light from directly ahead. Now your LDR will detect the reflected light from the LED when it is close to an object.

Good luck. I hope I have given you some food for thought.

Something I’ve been contemplating too

I thought I’d try using a optical mouse camera/LED/prism to see if the surface under the bot is moving or not. Just a theory, nothing I’ve put into practice yet, but an idea for ya to chew on.

The parts from the mouse they use are available as components so you can do away with all the extraneous mouse material. This method has a limited range (~1/4") and may be useless to you.

Thank you very much indeed

Thank you very much indeed for clear answer.

I had last night (must always wait children and wife are sleeping) some experiments with LDRs on my breadboard. This setting of two LDRs worked fine, actually i think it worked best with a bit smaller resistors than 10k. Originally i had idea that if i put another LDR into a tube, the resistance wouldn’t ever go near 0 but your setting is smarter.

Having “two LDRs voltagedividesytem” gives me another idea: this way you can compare values of two LDRs with a single analogue input. when for example right LDR connected to V gets more light than LDR connected to ground it gives different voltage to input compared to reverse lighting situation. I hope you understand what i mean. I think having both dimmed gives also difference in voltage because if both LDRs resistance vary together, another (connected to ground i suppose) affects more. I have to try this  out next.

Thats cool idea too. I have

Thats cool idea too. I have to check out if somebody has a spare optical mouse somewhere. I’m not sure if this is beyond my skills, as im quite a newbie robotbuilder :slight_smile:

I’d just see if the

I’d just see if the suroundings changed when I was moving. You know; If wheels are moving, but sensor is not making difference accordingly, you are stuck :slight_smile:

Confused about the question now…

Are we trying to PREVENT getting stuck and thus, are looking for answers about distance sensors and the like? --or-- Are we wondering what to do after the obstcal avoidance didn’t work and we are CURRENTLY stuck against a wall, etc?


This sounds more like

This sounds more like philosofical question for me :slight_smile: If you could be sure that distance sensors never fail, that would be enough to prevents stucking.You wouldn’t never mind the situation where robot has a problem. For my robot it is quite optimistic to rely on one longrange sharp IR sensor, so i originally thought that the very reliable way to make my little innocent cleaning robot able to survive in this wicked world would be monitoring the motors. But now i think its simply to  do it with bumber switches.


For Frits comment. I thought of comparing distance values but its a little bit hard job as my robot is scanning frontal sector and thus distance changes  all the times anyway .

But thank you for comments