Hmm...
I've not quite got it,..
the period IS the length of the pulses. In your first post, you say you want to keep the period constant, yet vary the width of the pulses. I'm afraid that doesn't make sense. They are the same thing.
In my duty cycle example, I've interpreted the application of what you've written, but not looked closely at what you've written, but I'm afraid the application isn't what you were actually after.
(I've done a varying duty cycle at a fixed pulsewidth/frequency)
It now sounds more like, you want to vary the width of the pulses, but you begin by saying you can't ?
I must admit I'm confused. This isn't for something like a 38kHz carrier wave, that you want to send a 600ms "on" over, then a 300ms "off" over or some such is it ? and they are your "pulses". PWM is very easy to use, but you have to have clear thinking about what you actually want it to do.
I always think of it as..
period=frequency.
duty cycle = percentage of "on ness" during each cycle in that frequency.
So, if you specify a 10 kHz frequency and a 50% duty cycle, you get a 10kHz square wave.
i.e. 10,000 cycles per second, each of them half on and half off.
You can change the duty cycle to 75%. You get 10,000 cycles per second, each cycle is high for 75% of the time, and then goes low for 25% of the time.
So, period gives you the length of the repeating unit, (the frequency), duty cycle gives you the "on ness" during that unit.
100% duty cycle is of course completely on !
50% duty means it goes high then low 10,000 times a second.
I hope this is all making sense. I'm now not sure of *exactly* what you want to do,
cheers
Hello, what I am trying to do is to send 10000 pulses out, increase the pulse width, send out another 10000 pulses, etc. The purpose is for the LED to be on at a low brightness for one second, then a little brighter for another second, etc. The problem is that my "reps" variable does not track the period in microseconds. The period must be 100 microseconds - that is not negotiable. Any help appreciated.