I am participating in a robotics competition that requires colour detection using discrete components.

The aim is to detect red and green lights of traffic signals.

I have tried making a sensor using photo transistors, but unfortunately they don't work very well, they are heavily dependant on the brightness and distance from the light source. And slightest of misalignment throws off the entire calibration.

Is there a better way of making a colour sensor, cost is not the issue? How can I make photo transistors work better?

EDIT: More Detail. The robot needs to navigate it's way through the arena following the traffic rules, throw a ball to knock down bowling pins and navigate back through another route. Off the shelf colour sensors are not allowed, ICs are allowed.

Major Edit: I contacted the organizers, apparently this is not just my problem, everybody is having issues sensing color using photosensor, off the shelf color sensors are allowed.

  • \$\begingroup\$ It sounds like you're focusing too much on a low-level detail of the problem. What is it your robot actually needs to do? Does it need to recognize a "traffic light" in the environment, and then determine whether that traffic light is red or green? Or is the problem more restricted than that? And why the restriction to "discrete components"? Does that rule out ICs of any type whatsoever? \$\endgroup\$ – Dave Tweed Mar 23 '14 at 13:42
  • \$\begingroup\$ @DaveTweed I have added more detail. \$\endgroup\$ – Hassan Mar 23 '14 at 13:58
  • \$\begingroup\$ Have you thought of adding photodectors with appropriate filters for the specific green/red wavelength ranges? \$\endgroup\$ – Tom L. Mar 23 '14 at 14:00
  • \$\begingroup\$ @TomL. I don't have access to professional filters, but I tried using ordinary transparent coloured papers as filters, they make absolutely no difference at best. \$\endgroup\$ – Hassan Mar 23 '14 at 14:33
  • \$\begingroup\$ Can you give an example of what inputs you are allowed to use? B/W camera? Ultrasonic distance measurment, ... stuff like this. \$\endgroup\$ – Tom L. Mar 23 '14 at 15:49

Sorry I'm writing this as an answer. It's more like a question. It's just that I'd have to post a series of "comments" due to text limits.

Ambient light can be a serious problem. I don't know what your ambient situation is, but it may include commercial LED lighting (phosphors and Stokes-shift and/or mixed wavelengths that trick the human eye), high-frequency compact fluorescent lighting (phosphors and Stokes-shift from mercury 254nm line), low-frequency fluorescent lighting (ballast, phosphors and Stokes-shift from mercury 254nm line), and incandescent (black-body radiation from hot source.)

You have to "think" like a sensor here. A sensor is sensitive to certain wavelengths and not to others. It can't tell if they come from "here" or "there" -- it's just one signal that it produces -- unless you limit its "sight" in some way (long tube, baffles, lensing, whatever.) It can't tell wavelenth X from wavelength X+Y. It can only sum its sensitivities and give you the total.

So how can you improve your signal relative to the background? One thing is to restrict your "vision" to the angles you consider important in sensing RED vs GREEN with the lights. Horizontal and vertical limits will help a lot in keeping out unwanted interferences and swamping out your sensors with unneeded light. So study up on ways to limit what you "see" as much as possible to "what you need to see."

Then you need to consider ways to limit the wavelengths. You need to discriminate here, anyway, so you have to do that somehow. This can be done by selecting sensors with different wavelength sensitivities. LEDs make pretty bad sensors, but a RED LED will have different sensitivies to wavelengths than will, say, a GREEN LED. You could explore that. Normally, with cost no object, you'd use good quality Hamamatsu detectors with thin film filters designed for your purpose.

There are other ways, too, to limit what you "see." Objects have spatial frequencies, as well. You could consider placing a baffle that blocks light at the Fourier plane in an optical system -- it's called "spatial filtering" -- and limit what you "see" to features with a certain spatial frequency. Look this up and see if you think there is anything useful there, as well.

If you haven't gotten the point yet, you need to do EVERYTHING you can think of to restrict what you "see" before it gets into the eletronics. Once it is in the circuitry, you are stuck with what you've got. It's LOTS better to keep out unwanted signals in the first place, than to be forced to work on methods to remove them once you have let them inside.

What ambient lighting environment do you have? What angles can you count on for your stop light positioning? (How early do you need to spot them and how late can you tolerate that? From what distance to what distance?) What do you know about the light emitters? What range of sensors are you permitted to use? Hamamatsu, for example, sells pre-filtered detector diodes. Even with amplifier systems in them, too, last I looked. Is that "discrete?" How much room can you afford for optics?

The lack of information here is driving me nuts. (You seem more focused on color detection and I think there are too many other important areas to consider before you get too deeply mired into that.)

  • 1
    \$\begingroup\$ +1 on mentioning the angles of the lights and the general idea about solving the problems before inflicting them on the electronics. \$\endgroup\$ – Andy aka Mar 23 '14 at 20:25

You fail to notice you could use 3 photo resistors with coloured lenses to detect whatever light you have to detect. Easiest way i know how to build a color light sensor

if cost is not a issue you might be interested in this product


You could use multiple light sensors (LDR, whatever) with colour filters across the front so you can discriminate a difference in reading between, say an unfiltered one, a green-filtered one and a red-filtered one to determine if green or red are getting an unusually high level.

However, seems fraught with difficulty to me unless the parameters of the traffic light are very rigidly defined to make your life easy.

Coming sideways at it, a PAL or NTSC camera (strictly speaking, an analogue device) could be used and then some cunning filtering of the video signal could be used to detect a "spot" of bright red or green within a certain area of the screen.

Hard work, but doable without going digital.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.