Hi all

I have bought Arduino UNO and a light color sensor.
I have never used Arduino before and have tried some examples but not sure what to do now.
I want to use the sensor to only recognise one specific frequensy, and in order to do that I have also a green filter that will only allow my desired frequensies.

Any feedback is more than welcome :slight_smile:
I think I have attaeched it correct as I get some results when I try the examples, but how do I change/write a program that do what I want?
I want the Arduino to check constantly and when the correct frequensy occurs I want it to give me a signal. So far I have not been able to get it to tell me any frequensies :frowning:


Do you really need the colour filter? The colour sensor should return the frequency of the light (reflected) from the object you want to measure. Putting a filter in front theoretically limits the sensor to a percentage yes/no for the masked frequency but if the light source used to measure with does not contain this frequency then the result would always be no.
You could probably just use an LDR with the filter fitted.

Link to data sheet of the sensor?

Hi Riva

Maybee not, but first we need to get it working :slight_smile:

Hi Magician

Here it is


I want the Arduino to check constantly and when the correct frequensy occurs I want it to give me a signal.

This what I thought, sensor light-to-frequency. But after visiting product web-page, it turns out it's Not the case. Sensor outputs digital stream I2C format, basically you need to write a software DRIVER for arduino to communicate with device. Task is too complex even for experienced programmers, definitely not for beginners. Your hope only too google if someone already create a library, for exactly same sensor or something close in hardware - software implementation.

Hi again Magician

Sorry, I gave you the wrong link
It should be this one

I did manage to get it working now, so it gives me frequensies.
Now the next step is to get some kind of "trigger" when the correct frequensy is present.


I did manage to get it working now, so it gives me frequensies.

If you have this part done, than everything else is a piece of cake, just couple "if" statement or even one "if" with &&.

Used a TSL235R last year which is also a light to frequency sensor and used this sketch as test of sensor code".
A trigger can be set by adding a timestamp in the IRQ1() and compare this with the prev time stamp (use volatile vars)

 *    FILE: TSL235R.pde
 *  AUTHOR: Rob Tillaart
 *    DATE: 2011 05 16
 * PURPOSE: prototype TSL235R monitoring  
 * Digital Pin layout ARDUINO
 * =============================
 *  2     IRQ 0    - to TSL235R
 * PIN 1 - GND
 * PIN 2 - VDD - 5V

volatile unsigned long cnt = 0;
unsigned long oldcnt = 0;
unsigned long t = 0;
unsigned long last;
unsigned long msec = 0;
unsigned int cf = 1466;  // cf = 10^0.166 * 1000 (figure 1 datasheet)

void irq1()

void setup() 
  pinMode(2, INPUT);
  digitalWrite(2, HIGH);
  attachInterrupt(0, irq1, RISING);

void loop() 
  msec = millis() - last;
  if (msec >= 1000)
    last += msec;
    t = cnt;
    unsigned long hz = (t - oldcnt) * 1000 / msec;
    oldcnt = t;
    unsigned long mw = (hz * cf/1000 + 50)/100; // +50 == rounding last digit
    // smoothing possible...
    Serial.print("FREQ: "); 
    Serial.print("\t "); 
    Serial.println(" mW/m2");



I am also stuck with the similar problem! I want to use a color to digital (or frequency, whichever is easier!) converter. I am new to arduino and programming. Though digging on the 'net gave me

Please if anyone can help me with this. I would like to use an I2C as I need to connect atleast 16 such sensors on the board. Though I would need to read from those sensors one by one (like an array or something), and not all together. Any suggestions?

Thanks in advance!