# Differentiation of Leds behavior due to light or color intensity ( fade in / out and slow or fast blinking?

Joined Feb 26, 2022
5
Dear All,
Currently, l am working on a project where l need to differentiate the led behavior due to light or color intensity. The aim is to identify the end of fade in /out and the beginning of slow blinking in sequential processes. l want to identify how long fade in/out and slow blinking continues.
the using photoresistor with Arduino in loop cant help to identify the stage when the value of resistance fade in/out is
Another method l have used is to connect the photoresistor to the capacitor for calculating the time difference for energizing the capacitor when the photoresistor is high less time or low more time needed to energize the capacitor. this way helped a little bit to get more accurate values but it is not enough to differentiate them.
l think the best way is using pulse width modulation but l need to convert light or color intensity to voltage. Which device or component can help to solve this problem?
l would be happy if someone can share his/her experience or ideas for solving this problem.

#### DickCappels

Joined Aug 21, 2008
8,710
Apparently you intend to characterize based on perception of how "bright" the LED is. For that you need a photometer. Good ones sell for a few thousand U.S. dollars to tens of thousands of U.S. dollars, but if that doesn't fit your bduget there is a way you can get pretty close for about U.S. 35¢, which is using a sensor that has a wavelength response similar to the (standardized) human eye's lluminance response as a function of wavelength, namely the CIE Y-bar curve, represented by the green curve below.

Attached is a copy of the BH1680FVC datasheet from Rohm. A CDS cell that comes close enough to matching the Y-bar curve might be found:

Silicon favor the red end of the spectrum and are not suitable for this kind of use. They are ok for a fixed wavelength but not for ok for comparing the "brightness" of sources at two different wavelengths.

As for determining when the LED appears "on" and "off" depends mainly upon ambient light and the treatment of the enclosing plastic lens.

By the way, you don't want one of those inexpensive Lux meters. You need a photometer. A lux meter uses an hemispherical integrating lens that takes in light from all angles, assuming that the ilumiination is even. It is a good tool for measuring ambient illumination. A photometer will measure the light intensity coming in a small aperture, so that brings up another tip: restrict light falling on you photosensor when measuring LEDs to a small area, preferably using lenses to image the LED.

As for fast blinking of the LEDs, Joyce Farrell (Xerox Park and Stanford) has published several papers in that are. In particular I recall her study of flicker response in CRT displays.

#### Attachments

• 422.1 KB Views: 1
• 18.4 KB Views: 0
Last edited:

Joined Feb 26, 2022
5
Thanks a lot for your answer. l will check them. Before starting this project l thought that only color or phototransistor /photodiode can help to identify the fade in /out and slow blinking.

#### dl324

Joined Mar 30, 2015
14,462
Welcome to AAC!
l would be happy if someone can share his/her experience or ideas for solving this problem.
Use sensors designed for differentiating color or intensity.

This is what I used when my daughter did a science experiment in middle school regarding LED brightness.

TAOS is now ams AG:

Joined Feb 26, 2022
5
Welcome to AAC!

Use sensors designed for differentiating color or intensity.

This is what I used when my daughter did a science experiment in middle school regarding LED brightness.
View attachment 261634
TAOS is now ams AG:
View attachment 261635

Joined Jan 15, 2015
6,585
If I wanted to do what it looks to me what you want to do I would set your Arduino aside for a moment. Currently there are dozens of data acquisition modules available out there, a Google of "data acquisition modules" should bring up a dozen hits. The magic isn't in the microcontroller but in the software included with these modules. They can store a signal in real time as it happens and allow you to view the saved file later, including automatic detections of peaks and valleys. Pretty much all of the work is done for you. These devices easily interface to a PC using any of several interfaces. You just want a sample frequency which is at least twice what you expect to see and most of the basic DAQ units have an input capable of +/- input (differential). I hyave used DATAQ and Measurement Computing modules but as I mentioned these are very common. You are running an analog signal into an A/D converter and plotting it. Fade in / out will look like a sine wave depending. Blink is also easy to capture.

Sensor choice is up to you.

Ron

Joined Feb 26, 2022
5
If I wanted to do what it looks to me what you want to do I would set your Arduino aside for a moment. Currently there are dozens of data acquisition modules available out there, a Google of "data acquisition modules" should bring up a dozen hits. The magic isn't in the microcontroller but in the software included with these modules. They can store a signal in real time as it happens and allow you to view the saved file later, including automatic detections of peaks and valleys. Pretty much all of the work is done for you. These devices easily interface to a PC using any of several interfaces. You just want a sample frequency which is at least twice what you expect to see and most of the basic DAQ units have an input capable of +/- input (differential). I hyave used DATAQ and Measurement Computing modules but as I mentioned these are very common. You are running an analog signal into an A/D converter and plotting it. Fade in / out will look like a sine wave depending. Blink is also easy to capture.

Sensor choice is up to you.

Ron
If I wanted to do what it looks to me what you want to do I would set your Arduino aside for a moment. Currently there are dozens of data acquisition modules available out there, a Google of "data acquisition modules" should bring up a dozen hits. The magic isn't in the microcontroller but in the software included with these modules. They can store a signal in real time as it happens and allow you to view the saved file later, including automatic detections of peaks and valleys. Pretty much all of the work is done for you. These devices easily interface to a PC using any of several interfaces. You just want a sample frequency which is at least twice what you expect to see and most of the basic DAQ units have an input capable of +/- input (differential). I hyave used DATAQ and Measurement Computing modules but as I mentioned these are very common. You are running an analog signal into an A/D converter and plotting it. Fade in / out will look like a sine wave depending. Blink is also easy to capture.

Sensor choice is up to you.

Ron

#### DickCappels

Joined Aug 21, 2008
8,710
You can use a phototransistor for this experiment. If you have a way to capture a wave form that could be useful in analyzing the data. Hint: You can an A-to-D converter and RAM in your controller.

If you use an internet search engine to find the term Flicker Fusion Frequency you can find many links that can help you understand the mechanism of flicker (fast flashing).

#### BobTPH

Joined Jun 5, 2013
4,906
I think everyone is missing the point here.? He already has a way of measuring the brigjtness. What he wants to know is how to determine from the collected data, which mode the led is operating in, fade vs blink.

From your data, it looks to me llke the rate of change from one sample to the next is what you need to look at. As a simple rough try, a change of more than 100 between samples would tell you it was in blink mode, based on the data you posted.

Bob

Joined Jan 15, 2015
6,585
I think everyone is missing the point here.? He already has a way of measuring the brigjtness. What he wants to know is how to determine from the collected data, which mode the led is operating in, fade vs blink.

From your data, it looks to me llke the rate of change from one sample to the next is what you need to look at. As a simple rough try, a change of more than 100 between samples would tell you it was in blink mode, based on the data you posted.

Bob
Bob, maybe I am seeing this all wrong. When I think fade I see a source of illumination, a LED, changing in intensity for example from zero to a peak brilliance (fade in) or fading from a peak brilliance to zero (fade out). Be it a LED or Incandescent light source actually I guess fade in and fade out could also be an audio level. Anyway that is how I see a LED fade ion/out. Blink I see as a pulse of light, the intensity can vary but the light source is either on or off.

This is why I suggested data logging making for an easy comparison of logged signals. Then too, I could be seeing this all wrong.

Ron

Joined Feb 26, 2022
5
yes, exactly this is what l want to say. fade in/out is like an audio signal (sine wave) and blinking is on/off.

#### BobTPH

Joined Jun 5, 2013
4,906
Bob, maybe I am seeing this all wrong. When I think fade I see a source of illumination, a LED, changing in intensity for example from zero to a peak brilliance (fade in) or fading from a peak brilliance to zero (fade out). Be it a LED or Incandescent light source actually I guess fade in and fade out could also be an audio level. Anyway that is how I see a LED fade ion/out. Blink I see as a pulse of light, the intensity can vary but the light source is either on or off.

This is why I suggested data logging making for an easy comparison of logged signals. Then too, I could be seeing this all wrong.

Ron
No, we are seeing it the same way. Fade changes only a little between samples, blink has dramatic change between samples that surround the transition. So you only need to look at the difference between successive samples to determine which it is.

Bob

Joined Jan 15, 2015
6,585
No, we are seeing it the same way. Fade changes only a little between samples, blink has dramatic change between samples that surround the transition. So you only need to look at the difference between successive samples to determine which it is.

Bob
That's how I see it. I just figured a data logger scheme might be a good way to look at things. Currently I am butt deep with a freezer that decided to die last night. New freezer on order and through a miracle I found dry ice on a Sunday. Fortunately the dry ice seems to be working. Should be good for 24 hours.

I hope to find time when the dust settles and just toss a simple LED on a proto board and add a simple CDS photocell and plot a few signals to maybe demonstrate what I am getting at using a data logging concept.

Ron

Joined Jan 15, 2015
6,585
OK, this will never make a top science experiment. Here is what I cobbled together. Using a common simple cheap LED I drove it with an Arduino just for a simple Fade In and Fade Out. The Arduino code is below.

int led = 9;           // the PWM pin the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);

// change the brightness for next time through the loop:

// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
Just so we know what we are looking at. I used a cheap CDS photocell I had laying around and placed it right beside the generic red LED. I used a data logger and only a 100 sample/sec rate and let it record. I let the software find the peak and valley. These are the images of the screen shots with the cursor on peak and valley. The voltage is displayed on the images along with time information.

Keep in mind this was cobbled together. Looking at the time I originally thought the ripple was 60 Hz AC but on second thought I think it might be the PWM rate. The sweep is about 0.2 Sec Div. Anyway this is my thinking and while not very pretty you get the idea. I could just as easily used a blink (On/Off) setting different intensities and get more of a square looking wave.

This is merely how I would likely approach it using data acquisition of some sort.

Ron

#### DickCappels

Joined Aug 21, 2008
8,710
Just a note: cadmium disulfide is notoriously slow.