Pages: [1]   Go Down
Author Topic: Using PWM pins for digital & analog writes alternately?  (Read 834 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

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 smiley
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8821
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8821
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Pages: [1]   Go Up
Jump to: