THIS IS THE ANSWER
Well… It may be a shot in the dark, GroG… and you may put it in other words than I would… But you are absolutely right!!
My way of saying this would be:
- Make the LED flash on and off each time the LDR is measuring.
- Work with 2 samples in every cycle instead of just measuring the input: Sample one where the LED is On and one where it is Off.
- The 2 inputs are substracted from each other, and…
- THE DIFFERENCE between the two is what we work with here
Point the whole thing out towards outer space, and no difference is reflected to the LDR if the LED is doing it or not.
Point the LED to an object that reflects the light, and THE DIFFERENCE in the amount of returned energy is the same…
…even if the general level is higher (more light on) or lover (black night) - because the LDR is “lifted” to be somewhat “in the middle of the scale between black night and bright daylight” with the mounted resistor, and measuring is in word-variable-resolution (picaxe language: readadc10)
Of course it has reading-problems on black mat surfaces. However, primary testing shows that it can easely be set up to detect black things as well, however thinking they are further away than white ones. But this also goes for IR-detectors, only here you can acually see it all. My experience of working with a SHARP IR rangefinder is that it makes the robot very “analouge” - it is not really distance that is measured, but sort of a feeling of it…
The strenght of the LED / LED’s means a lot to the effective distance we can measure / detect with this method. That is also why I am actually working on some other method. At test time, I tried to over power a red LED, and boy, ow we where talking; It could measure the distance to my hand at up to 50-60 CM!
I will make some test with both more LED’s at the sme time, and also putting the LDR into the “shiny metal thingey” of an old flashlight.
The really interesting thing here IMO is that having multi coloured LED’s and making more samples pr cycle (one for R, G, B, none for instance) will provide color info on the target - and then a white LED may better judge distance now that we know the color… and knowing color and distance by a couple of LED’s, an LDR and a few lines in a sub routine to be called any time is quite handy!
As asmith.id.au points out: “if you could get it to work under mains powered artificial lights” - well the first test showed that i’d have to reduce sensivity quite some for it to work straight under a light bulb; The 50 Hz did course interferrence if we work with EVERY little difference - and that is nice to do. So I may have a look at filtering this either by “morse-code” in the on/off, or by something with the more colors of LED.
An extra feature is laser: Hook up a laser(pen) to the output of the LED, and you get insane sharp results when pointing the laser at the LDR! The laser does not work to reflect the light, but with this you can have a laser-beam that you can detect no matter it it is sun is out or not… for the price of an LDR
Thanks for participating! The answer was all in the programming;Use 2 cycles, one on one off, work with difference. When Jklug80 wanted to detect if some object on the floor was a bottle cap or a tables leg, I suggested the same; 2 cycles. A) Measure the distance to the object B) make something poke the object, and measure again. If it has moved it can be picked up
(And NICE ONE GroG, you have been granted STREET CREDIT AND RESPECT :D)