Hi jjw,You need braces after while statement.
I don't know if the compiler accepts the while statement as it is now.
Probably the statements in pwm_up and pwm_dn are executed only once
Should be something like this:
---------------
void PWM_UP()
{
//for (int i=0; i <= 60; i++) //need to add .333 sec delay somewhere for a 20 sec overall fade down duration
while( delay1 > 0 && delay1< 10000)
{
digitalWrite(ledPin,HIGH);
delayMicroseconds(delay1); //increase duty cycle at 100Hz - delay #1 - HIGH
digitalWrite(ledPin,LOW);
delayMicroseconds(delay2); //delay #2 - LOW
delay1=delay1-delayValue;
delay2=delay2+delayValue;
}
}
Same for PWM_DN()
I'm quite sure the actual fade sequences, UP & DN, are looping properly. They are simply looping too fast so it appears as a blink on/off approx 7 times per second. The entire sketch loops 7 times per second, continuously. My problem now is, I need to create a 1/3 second pause every 55 (changes in pulse width) loops of the UP & DN functions, which would take approx 60 seconds. 60/.33=180, 10000/180=55.55
I'm working on implementing this scenario now. MikeMI has been a huge help over the last few days, but I just can't grasp specifically what he is conveying and that is on me, of course.
Maybe he'll chime in later....
Thanks for your input.
I did a bit more testing using the 500Hz PWM signal (analog 1-255) to my led driver and although there is fading, it is obviously not fading smoothly and does not like the 500Hz so I do need to get this Hz coding figured out so regardless of an IC or modules requirement, I'll be able to adjust for it.
Last edited: