Line Following Sensors

Hello everyone,

I am making a line following robot for a competition in Australia called "Robocup Junior". It involves following a line, also, taking shortucts indicated by a green square. At the suggestion of one of the friendly LMRians I invested in an IR Sensor board that can follow the line perfectly. The only problem I have been having is that white and green have the same readings (must be a problem with infra-RED and GREEN being different, or something:)

So I am creating this thread to see if anyone has had any experience with any light or colour (color) sensors.

The sensor needs to have a conserable reading difference between black, white, green and silver (aluminium foil). An optimal reading distance of more than 5mm would be ideal.

Thanks for your help.


P.S. - Ease of programming is also quite important as I am a beginner.

For inspiration and ideas

For inspiration and ideas have a look at this one.


Hi Riddellikins,

I have entered robocup junior in NZ using an arduino and five of these:

While they could only tell the difference between white and black, I could overcome this by detecting an intersection, all sensors on black, and then turning the correct way based on a preprogramed sequence; eg, left, left, right, right. They could also be used to detect the silver foil easily. I thought about buying color sensors, but never got round to it, and the reflective sensors are so cheap ($2 for 10, worldwide free shipping).

What level of rescue are you in? , I might post my premier rescue robot here soon, if i have some spare time. I will be making some improvements and entering it into this years contest, along with my raspberry-pi soccer bot which is very much a work in progress at the moment. I look forward to hearing more about your robot!


You don’t need a line sensor, you need a color sensor

Sounds like you need a color sensor. I invite you to do some googling, but it comes down to 3 LEDs (red, green, blue) and a LDR. Each of the LED’s gets turned on (or combinations of them) and readings are taken. Based on different colors reflecting and absorbing different wavelengths of light, the LDR spits out different numbers.

The M&M sorter used a DIY color sensor as I recall. Parallax carries one off-the-shelf as well.

Did you win? :slight_smile:

We only have two people that actually made their own robot for the competition, the rest were just Lego. I’d imagine that if your robot worked then it would wipe the floor in our competition.

I came 1st in Brisbane Regionals, 2nd in States and I think it was about 15th (or something) in nationals. This was with my trusty Lego robot but I realised I needed to do a custom built one if I was going to do much better.

I have a pretty epic arm mechanism that I made with 2 servos, Lego technics and my 3D printer that I got for christmas. I just need to get the shortcuts and silver working otherwise I might as well have nothing. I think I might try Chris the Carpenter’s suggestion; I can see how it would work and I already have most of the LEDs.

As for the sensor you suggested, I do believe that I have IR sensors already on the line sensor that I purchased. So buying more would seem a little silly. :smiley: You solution to the shortcuts problem is genius although the preprogramming may be bending the rules a little, at least in our competition.

Thanks for your help anyway.

I’ll give it a go!

Sounds good: cheap and simple. I like it.

Would I be right in thinking that an LDR just acts exactly like a resisor? Would wiring it like this work? VCC -> LDR -> Analog4

Thanks for your suggestion.


Yes and no

Yes, it works just like a resistor --except it changes its value based on how much light is hitting it. However, the wiring you describe is not correct.

You will need to create a “resistor bridge” with your LDR going between a ADC and ground and a pull-up resistor from that ADC to vcc. I would suggest using a pull-up resistor of the same value as the LDR --I.e. 10k LDR and 10k pull-up.

I have done some Google-ing

and I think that I have got it. I thought pull-up resistors were a special type of resistor (more money) but I was wrong. :slight_smile:

Thanks for your help Chris.

Just to be nitpicking a bit here.

What he needs to create is a ‘voltage divider’ and not a ‘resistor bridge’. And I don’t know if you should call the 10k resistor from ADC to VCC a pull-up resistor as it’s just one half of the voltage divider.
Pull-up resistors are related to digital signals to set a pin/signal to a known state.


They are perfect

I went out and got some LDRs and a few LEDs. It is just what I needed and works perfectly!!