2

I got this color sensor last week, I've been able to get the sensor to recognize blue and red, but not green. still working on this. I use the code in the product page.

so anybody have any idea about this issue? Pretty thanks. enter image description here

4

Check that you've connected all the Arduino pins correctly to the sensor. In particular, make sure pin 4 on the Arduino is connected to S2 on the sensor.

It's the combination of signals on S2 and S3 which determines which colour is being detected:

S2    S3    Colour
----  ----  ------
Low   Low   Red
Low   High  Blue
High  Low   Clear
High  High  Green

If S2 is always low then you can only detect red and blue.

If the connections are definitely correct, then ensure you haven't made any code modifications which could interfere with it. You may also want to test pin 4 on your Arduino (e.g. using a multimeter) to make sure it's working properly. If necessary, you could use a different pin instead. However, you'll need to modify the #define S2 line in the code to match.

  • Wouldn't clear just be the color on the other side of the object? Or do you mean when it is out of range? – Anonymous Penguin Dec 15 '14 at 0:08
  • @AnnonomusPenguin That's the wording used in the datasheet. The device consists of a basic light sensor with a selectable colour filter. Clear means there's no filter, so it will simply detect the brightness of all visible light falling on it. If you apply the red filter, it mainly detects the brightness of red light, and so on. To detect the actual colour of something, you have to take three readings to get the RGB components; i.e. one with each filter applied. – Peter Bloomfield Dec 15 '14 at 9:51

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.