How to code for when a change in colour an LED will go off?

Discussion in 'Embedded Systems and Microcontrollers' started by brent-meister, Nov 21, 2015.

  1. brent-meister

    Thread Starter New Member

    Nov 16, 2015
    3
    0
    Hey guys, I'm very new to Arduino. I bascilally have a colour sensor and been playing around with it but i want to make it so that when the sensor picks up/ or goes over a certain threshold an LED goes off. How can I do this?

    Cheers guys!
     
  2. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    You could provide a link to the sensor data sheet, or otherwise tell us how it works...
     
  3. brent-meister

    Thread Starter New Member

    Nov 16, 2015
    3
    0
  4. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    ada.gif is the basis of how you interface it.

    Do you have all of the example code working>
     
    Last edited: Nov 22, 2015
  5. RRITESH KAKKAR

    Senior Member

    Jun 29, 2010
    2,831
    89
    Hello Brent,
    What are you making color sensor or want to make color on leds?
     
  6. RRITESH KAKKAR

    Senior Member

    Jun 29, 2010
    2,831
    89
    If you are using or want to make several color pattern on leds.
    then PWM the legs or you want to read color then ADC[​IMG]
     
  7. JohnInTX

    Moderator

    Jun 26, 2012
    2,341
    1,024
    On pp17 of the document you posted there are library routines for light readings. It looks like getRawData(...) would do what you want. This function takes pointers to 4 integers, RGB and Clear. 'Clear' covers a relatively broad spectrum and could be used for intensity I would think.
    'calculateLux(...)' might be better as it returns a usable Lux value from the sensor. Just compare the returned value with your setpoint and act accordingly.

    The datasheet for the sensor chip itself is attached. It has lots of interesting info but it looks like the AdaFruit library has all you need. Connect it to the I2C port and have at it.

    Have fun.
     
Loading...