Let's Make Robots!

New ways of seeing things..

Hi all, I am so excited about this. It may not be much to anybody else, but to me it is!

You all know how we only have the IR's or the Ultra sound to work with when we want to check distance? Yeah, if we have millions we can also get a camera or two, and laser range finders..

However, I wanted something cooler.

This is not that, I am sorry.

However, I am working on something cooler (I hope, but it may be far fetched), and when doing so, as a spin off I made this. 

And it is pretty wicked, I think.

The setup is simple, as simple as you can see it on the video; An LDR (Light Dependent Resistor) is hooked up with a 330 Ohm (or something) resistor, to the analogue input of a standard Picaxe 28 board with no extra modifications.

Also a speaker and a "white" (pale blue they are) LED are hooked up to the standard outputs, batteries, and that is it.

At first you may think that I have done nothing special.. LDR detecting light, or maby just pulsating light.. but then why don't you try to replicate it? I am going to be very surprised (and my day spoiled) if you can make something that works like this! ;)

I have made an LDR measure distance!

There you go, for less than half price of a Sharp IR range finder, and twice as fun, as you can actually see where the robot is focusing!

I am so excited to hear what you all think of this, and to hear if anyone can figure out how I did it, so I am not going to tell yet, but I will make a walkthrough, and am planning to make a robot (Start here-kind of project) that will not drive over the table's edge, and will navigate just by this.

..And while I am at it, I think I may have a look at giving that robot the ability to sense colors as well, so it can find say a red object amongst green on a black surface.. and then it can play ball :)

Because color detecting is also a spin off by this method! (Not on the setup on the video, and I have not tried it in real life yet, but I am pretty sure, and am going to prove it soon :)

And if not for color sensing, then for coolnes: Yes, the LED can be red as well (or any other color, possibly even IR, though I have not tried it yet) In fact it was red when I made the original test, but I swapped it to a "white" so you should not think it was the difference in color that did it. The flash light on the video has 3 LED's of same type & color..

How did I do this? Make me happy, throw me a theory, or try to duplicate :)

Thanks (I will tell later, but here is a chance to take me down first ;) Did I mention it is working in sunlight?

Comment viewing options

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

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)

Sorry Fritzl, you're still wrong because you are just guessing about what your circuit and program are measuring. Until you can make an accurate graph of the results and interpret them you won't be able to figure out what's really going on in your circuit, even though you think you know now.

The first part of GroG's suggestion is actually bang on the money. That your circuit works at all is just a fluke because of the constant time gap between your two measurements. However if you were to continuously measure the output from the LDR and analyse the resulting curves you might be able to get a more noise resistant result which might be useful in some environments. You would need to use a fast fourier transform and while it can be done an 8-bit PIC, it can't be done fast enough to be useful here. There is sample code written in assembly language that you can download from Microchip's website if you want to try it for yourself.

However you are still not going to be able to do anything in the presence of mains powered artificial light. The reason is simply because the LDR can't operate at more than around 100 hertz which is the same spectrum (50 to 100 hertz) as mains powered lights. That's why range finders use phototransistors and operate them at 40 kHz. The receiver uses a band pass filter to extract the real signal and then measures the amplitude of the result.

I could go and on but I won't. I think it's clever what you've done, but it is unfortunately neither novel or more than a curiosity.


How can I be "wrong"? Wrong in what? The question here is how I did what is on the video, and I have answered that - wrong? Hmm? :)

I am going to make a robot that navigates with this alone, and uses it to not fall off a table.. so I may be wrong to the clever people, and my robot may be wrong as well.. but if it works, then I would say that it is right :)

You are wrong in the sense that you have made a proximity sensor that can only work in the dark. You have not made, as you claimed, a useful new kind of rangefinder.

If you were to actually measure what you are getting instead of just listening to the speaker, you would have realised that the results are too wildly inaccurate to be used for range finding. I really hate to rain on your parade (well may be just a bit but only because you were being a jerk the way you were teasing everybody earlier) but until you accept that subjective observation is worthless, you won't get anywhere.

Objective observation means taking the time and effort to take painstaking measurements and then analyze them. For example the graph that I just posted for the behaviour of the motors of my Ozone robot showed me why it wasn't possible to control modified servo motors accurately using the software that I'd been writing up to that point. Maybe I can still develop a sophisticated enough model of the motors to control them, or maybe not, but at least I am no longer guessing about why my control software didn't work.

In the broader sense, this approach to solving problems is called The Scientific Method. Without employing it, the only inventions that you can come up with will be little better than snake oil.

Well.. I have tested this in broad sunlight, and it works. Even in conditions where I cannot see the light myself.

Me, being a human, I cannot tell if there is 250 or 350 meters to something just looking at it. But I still drive a car. My robo's purpose is not to measure distance excact (i'd use a laser distance meter) - but to navigate. And I think it is cool that you can see where it navigates (when the lights are off)

The example code of the SRF05 to the Picaxe has some calculations so you know how many inches or centimeters things are in front of it. I always strip that part of the code, I just need a number, and I make the robot navigate from that.

i understand and respect that you cannot cope with this way of thinking, you clearly belong to the clever side of us. However, I make a robot navigate and avoid obstacles with this.. in broad daylight. Or at least I make it avoid falling off tables.. in broad daylight.

So wrong or inacurate or whatever - I make robots, they navigate etc. And because of this method I can now make a robot that navigates using LDR and LED to measure distance (if you like it or not :) You can deny it all day, it may not be right, but.. 

You will find that light dependent resistors are more sensitive to green LEDs than other colours, so using a green LED would use less power. Other than that, you are right, the colour probably doesn't really matter. (I corrected this after reading the Wikipedia article.)

Also, it would be more useful if you could get it to work under mains powered artificial lights.

Actually it turns out that a red LED is giving remarkably more signal than any other, including the White.

Infra red still not tested.

All LEDs are not created equal. It may be that the red LED has a higher intensity of light than the green. A bright light is always going to be brighter than a dim light regardless of its colour.
Dang! That's what my own tests showed too when I was working with LDRs, that red worked best. Then I read that article and figured that in the general case they ought to know better than me, which is why I corrected it.

Dare I say practice VS science? :D

Sorry, I know it was too easy a joke to make, and you are already shot down because you could not figure out how I did it, and GroG could AHAHAaa.. oh, sorry ;)