Flickering led at specified frequencies precisely

Hello All,

I am trying to make a project in arduino, where LED light bulbs should flicker at a specified frequencies precisely. Also how to vary the brightness of the LED at that frequency. Are there ways that use other than Pulse width modulation.

Thanks in advance,
G. Gnanasenthil

Hello. What frequencies? How precisely? Give us numbers. Why do you not want to use pwm?

Paul

Thanks for the reply.

I will like to use frequencies from 1 hz to 200 hz.

Regarding precision - anything better than that is got by using delay() function.

Regarding Pwm - I didn't want to use it because, I wanted to control both the brightness and the frequency also as I read here the number of levels that the brightness could be controlled is way to less (6 levels as shown in the diagram), I want a much more number of levels. Can it be done manually by hard coding the duty cycle and the percentage of on and off times or are there any better ways?

Does the absolute on time during a duty cycle determine the brightness or it is the percentage on time of the duty cycle that determines the brightness?

I am planning to control both the frequency of flickering and the brightness level using python.

Previously we did it with external potentiometers one each for for adjusting brightness and one for frequency, but somehow the with the potentiometers I was not able to have a precise control over the adjustments.

I think we have a X-Y Problem going on here.

There is a lot of detail missing. You talk of precision in a vague hand waving way. There are two elements you need to address here. How many steps you want the frequency to change in and when you change it how accurate the frequency you obtain is.

Also how big are these LEDs? Normal 20mA jobs or high power devices? It matters for your dimming solution.

Regarding Pwm - I didn't want to use it because, I wanted to control both the brightness and the frequency also as I read here the number of levels that the brightness could be controlled is way to less (6 levels as shown in the diagram), I want a much more number of levels.

I think you misunderstood that page, it says no such thing. Using PWM is not the answer however because of the precision you claim to want.

Does the absolute on time during a duty cycle determine the brightness or it is the percentage on time of the duty cycle that determines the brightness?

It is the ratio between on an off that controls the perceived brightness of the LED. As long as the frequency is above the persistence of vision at about 30 to 50HZ.

Previously we did it with external potentiometers one each for for adjusting brightness and one for frequency, but somehow the with the potentiometers I was not able to have a precise control over the adjustments.

Did you try using ten turn pots?

I shall share what my requirement is - that way things become clearer..

I want three LEDs (of different colors) to flicker. I should also be able to control their flickering frequencies (range 1hz to 200 hz) and intensites of each of them.

Lets leave the precision part.

What are the options available?

gnanasenthil:
I want three LEDs (of different colors) to flicker. I should also be able to control their flickering frequencies (range 1hz to 200 hz) and intensites of each of them.

A frequency greater than ~20-25herz is not seen (by humans) as a flicker, but as dimming.
The lightbulbs in your house flicker at 50 (or 60) herz. Do you see them flicker?

You didn't answer Grumpy_Mike's question of how big the LEDs are or must be.
If you need small ones, Google addressable LEDs, or Adafruit Neopixels.
Leo..

I actually want to take the frequency from 1 hz to the point where it is seen stable(persistent) and at each frequency I need to control brightness from a arbitrary min to max.

The size of LEDs I am experimenting are approximately 5mm wide.

Regarding frequency at which flicker disappeared was some where near 70 Hz with my previous setup.

As I said :- I think we have a X-Y Problem going on here.

to the point where it is seen stable(persistent) and at each frequency

What is it ?
Are you trying to make a stroboscope? If so what are you trying to look at? And why:-

I need to control brightness from a arbitrary min to max.

You might think you are answering questions but you are not in any way. This is like trying to get blood out of a stone.

Lets leave the precision part.

You can't because that affects the viability of some options. Once you have achieved "stability" what do you want to do? Display the frequency or just look at it?

I want three LEDs (of different colors) to flicker. I should also be able to control their flickering frequencies (range 1hz to 200 hz) and intensites of each of them.

So is this interdependently? That is are all three LEDs going at the same rate? Or do you want separate control of each colour.

The size of LEDs I am experimenting are approximately 5mm wide.

But what current do they take, the physical size is totally irrelevant.

Grumpy_Mike:
Are you trying to make a stroboscope? If so what are you trying to look at? And why:-

Once you have achieved "stability" what do you want to do? Display the frequency or just look at it?

No I am not making stroboscope. I just wanted to display the frequency.

Grumpy_Mike:
So is this interdependently? That is are all three LEDs going at the same rate? Or do you want separate control of each colour.

It would be better if I can control the frequency and intensity of each led separately.

Decide if you want to use two leaded LEDs or serial LEDs. Serial LEDs will be a lot easier to use.
Mixing in PWM for brightness control of two leaded LEDs will be a little more complicated.

Create an approximate 60Hz timebase (millis should be workable).
For each led declare a counter variable that will count the timebase ticks for time on and time off.
The counter times are held in another two variables time_on and time_off.
You can calc. the frequency from the time_on/time_off variables.

Thanks,

I found an article here. But it does not cover how to modify brightness.

Rather in the same way as you don't answer questions. I will make no more contribuitions to this thread until my questions have been answered.

gnanasenthil:
Thanks,

I found an article here. But it does not cover how to modify brightness.

If that code does the basics but you want to add variable brightness, simply replace digitalWrite(pinX, HIGH) by analogWrite(pinX, brightness value) and provide a means to set it. First try it with a value of 255 and compare the result with the original code.

I suggest that you read serial input basics - updated if you need extra information how to handle serial input. Be aware that serial comms might affect the on/off timing.