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

Thread Starter

brent-meister

Joined Nov 16, 2015
3
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!
 

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
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!
Hello Brent,
What are you making color sensor or want to make color on leds?
 

JohnInTX

Joined Jun 26, 2012
4,787
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.
 

Attachments

Top