Go Down

Topic: Using PWM pins for digital & analog writes alternately? (Read 1 time) previous topic - next topic



Suppose I use Arduino Uno to build a 3x3x3 LED cube. The patterns would
be displayed using the digitalWrite() function.
The PWM pins would be assigned to 6 of the 9 columns on each of
the 3 layers. Can I employ these pins to intermittently use the analogWrite()
function, so as to fade-in & out at least 6 of the 9 LED's on each layers?

In short, can I employ the PWM pins to use the digitalWrite() & analogWrite()
functions alternately for on/off & fade-in/out respectively on 6 LEDS of each of
the 3 layers?

Thank you :)


You can switch between analogWrite() and digitalWrite() as frequently as you like.

One problem with using PWM pins to drive the columns of a multiplexed display is that the multiplex frequency (the rate of switching between rows) might be close to a multiple of the PWM frequency.  If so you'll get a throbbing or blinking effect rather than a constant dimmer value.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


Oh so that means if I want to drive 5 columns using the PWM (common anode to each pwm),
it wont have the desired effect of the columns fading in & out but would strobe/blink.
That sucks. :-) Thanks John for letting me know why!


You can do PWM in software such that it will be synchronized with the multiplexing process.  This take a good deal more programming but it lets you fade individual LED's in any combination.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Go Up