Let's Make Robots!

How to make AmandaLDR

Make a robot sense stuff in dark or light conditions.. guided by visible light

Update: I am tired of it being named "FritsLDR", I cannot post to people "Try using FritsLDR", it is just too self centered. And I would just love to see some more people trying it. 

So it is hereby officially renamed "AmandaLDR", named after my first dog Amanda, that died because it ate rat poison. RIP.

I call it FritsLDR because it had to have a name, and my wife would not be honered anyway. However I think it would be fun to see if people at other sites would talk about it, using this name :) I cannot patend this and make millions, so at least I can try to get some street credit, name something after myself :) You can of course call it what you want!

What does it do?
This is a method of making a robot (or any other piece of electronics of course) sense objects in front of it - only by using light that is also visible to the human eye. Here is a link to a robot that uses this: http://letsmakerobots.com/node/1823

What does it not do?
This is not usefull if you need acurate distance to objects, only to know if they are close, or perhaps "very close".

What can it be used for?

  • Line following robots
  • Make your robot stop before it would fall off a table or the like
  • Experimenting and fun (since I have only just begun this, and it is fun to work with something that you can see)
  • Cool flashy robots - really. Video is not doing this justice; It looks COOL (specially at dim light) when a robot is navigating by flashing LED's
  • Object avoiidance - specially in near field
  • Point a laser (that is hooked up like the LED's) and the beam can be detected in sunlight or at night.
  • Make robots send flashy signals to each other
  • Try other sensors than LDR's? Photoresistors?
  • Have fun at a very low price (cheap and accessible components)
  • Make your robot detect colors / seperate one object from another!
  • Make your own sensor is fun :)

How does it do it?
It is so simple that I know many people will say that this is "nothing". However, it has never been done before (please send me links if I am wrong) and it is so fun to play with.. so I stand by my statements of calling this an invention, and naming it after me ;)

Oh .. how.. yes.. Have an LDR (Light Dependant Resistor) and an LED (Light Emitting Diode) - both very cheap components hooked up to a microcontroller.

The bigger the LDR the better (because it is more sensitive).

The LDR is hooked up to an analouge input of the Microcontroller, and a resistor is applied so that it is "resting" somewhere that you can read both more and less light.

More LDR's can be used on same analouge input, and of course multiple LDR's can be hooked up to multiple analouge inputs, thus making multiple sensors /variables to work with in the code.

The more LED's the better. The brighter LED's the better. The LED's point at the object measured, and the LDR is at an angle / shielded so that the LED's direct light does not influence it, but what the LED is shining on is reflected back on the LDR.

All LED's are just hooked up on the same output pin if you wish. It does not matter (or only makes it better) if other LED's are on when you are measuring one LDR.

The above is not new, all IR detecting works like this.. The tricks - the FritsLDR lies in this:

Instead of measuring light and trying to guess how far things are, we are measuring twice pr cycle, one with the LED on, and one with the LED off. And we do not care about the results, only the difference between the results.

Big difference; Your LED was able to make a difference, so there is something there. And it is containing the same wavelenght as your LED. (White contains all, yellow will reflect both red and green light.. green objects will only be seen by LED's containing green light, such as yellow, white or green LED)

Small / no difference; Your LED did not make an impact. So either the object is mat & black (like the black lines for a line follower), or the LED's are pointing to something too far away, like over the edge of a table.



What you need is something like this:

One or more LED's hooked up to an output port of your microcontroller. Make sure the LED get's all the power it can take, by ajusting with resistor(s). My experience tells me that usually a 330 Ohm resistor on a 5V output (like typical darlington output on a Picaxe 28 board) works wonders.Please do not ask meabout how to calculate this with many LED's etc - we have clever electronics guys for that, ask in the forum, thanks.

All LED's on same robot can be hooked up to same output if you wish. It only makes it better if some sensors also gets reflection of other sensors LED's.

Any color can be used. However, if distance matters to you, I recomend red LED's.

It is IMPORTANT that the LED's are of the "clear" type, often refered to as "super bright". The kind that you cannot see which color is, before switching it on. This is simply (to my knowledge) the only kind that is powerfull enough to go beyond very narrow.

(Make sure the LED is turning the right way - short pin, black, ground)

LDR(s) hooked up to a (preferable high resolution, but 256-value will do) analouge input, with a resistor on so it is "resting" at a fine middle value.

Sorry for the uglyness in the picture (this is made fast, it was just parts I had laying around)

  • Black goes to ground
  • Middle red goes to analouge in
  • Other red goes to V

Between the wires is soldered a (small) LDR, and a 330 Ohm resistor.

For Picaxe users: The above will fit onto the 28 board if you solder an extra pin into the analouge part of the board (see 28 pin Project Board (AXE020), Picaxe for dummies)

So the whole circuitry for the simplest setup (one LED, one sensor) will look like the picture above. Yes, the 2 black (ground) are touching each other.

You should be able to swhitch the LED on and off, and be able to detect this light with the LDR.

Now see the attachment on this page, there is a code for this. It is written in Picaxe Basic, but is well documented, and made as simple as possible, so it should be universal.

You can also make your own code, and you can have a look at the example below, tips on making the construction itself:

This is a brief look through making a sensor that can be used to stop your robot from falling of a table etc.


If you are looking at using this for object avoidance, I recomend some setup like the one on the main picure above: Large (shielded) LDR, and multiple (red) LED's.

I am using a perf-board to mount 2 sensors, each with one LED close to it. So step one would be; Get some perf board :)


If you are going to use this for line following, you may want the distance of the LDR's to match the black line. (I'd say that mine are too far apart on the picture)

Of course if you just want to test the whole "FritsLDR-thing", one LDR is enough, and the code is optimized for this.

Place the LED(s) as close to the LDR as possible.. but make sure to leave some room for shielding. You may want to add some black plastic on the edge of the LDR to prevent false readings.

If distance really matters, the setup on my picture is not that good, as the LED is close to the object, and the LDR is further away. It is in fact a matter of getting the LDR as close to the object as possible.

If you want, you can make sure that the LED's point in an angle for optimal reflection to the LDR. However, don't overdo this; My experience tells me that it does not matter as long as they are not pointing away from each other.

- And there you go, really. I am not going to show you the backside of my board, it is a mess of wires and solder :)

However, I recomend that you some way mark the wires (and perhaps even add female headers on them) so that you know what is what later on.

 I cannot wait to see your flashy robots!! :D

Comment viewing options

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

Can I use this circuit for detecting opponent and charge onto it for my SumoBot? *We need to build an analog sumobot without microcontrollers. 

How does this work? No pull-up resistors i think?

Is there a way to use this on a digital input ie when it gets above a certain level because i would like to use 4 of them and a sharp ir sensor. I am using the picaxe 25 project board with 4 anologue inputs

Must put this on my list of things to do. It's growing daily. Will I live long enough......?

when i measure the voltage drop in the photoresistor its only .7v   is this acceptable?  anyone? (Oddbot ahheeemmmmm)   =)
I assume by photoresistor you mean a LDR. Please post a diagram of your circuit.
yeah ill post it later  and the actual picture... im gonna try a smaller LDR cause the one i used is as big as the picture above with  6 LEDs...i plug it on picaxe b0 just read 231 when on the edge and 241 when not on the edge..is this normal?little difference? im also gonna try to put a black tape around the LDR or the LED..later gotta go to school :)

Majones  & OddBot:

Good findings & Results! Please dump us as much simple / low tech info as posible.. When I hooked up lots of LED's, they where not very rational; some shine more than other. I do not dare thinking on how bad it would be with IR when I cannot see what's going on!

I'd really whish all was in visible light, but I gues you ell me that IR is beter? (Even when it is not modulated?)

LDR_amplifier_Schematic.jpgOn the right is a simple amplifier for an LDR. You need to adjust the pot to suit the lighting conditions. The problem with LDRs is that their resistance can change so much with different amounts of ambiant light that this circuit is better suited for detecting when the light gets above or below a certain level. To make an LDR work better as an object detector you may need to put a lens in front of it. This is one advantage of a phototransistor, it has a lens moulded into the casing. If you put the LDR into a black tube then it will only respond to an object directly in front of it.













Try an optical setup like this.


 Even if you don't have the lens, this setup and the amplifier could improve your range. Frits's prototype in the photo has a bit of heatshrink for the tube. My suggestion is to make a longer tube to eliminate ambiant light better.

I didn't mean to say that IR can't be read analog, just that the three pin demodulating IR transistors kick out a digital signal.  I should've clarified.  Idea 1. was to fire out remote control comands with the IR, and look for them with a 38 khz remote control receiver. 


It did occur to me that I could use ir leds in place of the regular ones in this design or one like yours, if I decided I didn't want to strobe people in the face when they look at the bot. But what would be the fun of that?  I say, dazzle 'em.