Pages: [1]   Go Down
Author Topic: fading out LED on non-pwm pins?  (Read 590 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I am trying to do a fade out (not fade in/fade ou, just fade out) on some LEDs connected to non-pwm pins of arduino, so basically cannot use analogWrite. Does anyone have any idea how i can do that, or fake pwm?

thanjks
ayah
Logged

Las Vegas, NV
Offline Offline
God Member
*****
Karma: 0
Posts: 507
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Software PWM using either a timer to determine when to pulse the pin or delays.

- Ben
Logged


Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

another way is to use chips that can generate PWM, or a digital variable resistor. I think there's something on variable resistor in the playground.
Logged


Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34243
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The other way is to connect the cathode to ground and the anode through one value of resistor to one digital output pin and the same anode to another resistor of twice the value to another digital output pin. Then you will have 4 levels of brightness available (one being off).  In software make the pin an output and put it high, or make the pin an input to add or remove the current contribution from the resistor.

If you an another resistor and pin you have 8 levels and so on. Values to use would be 200 ohms, 400 ohms and 800 ohms, or as close as possible to those values it doesn't matter too much.
Logged

Pages: [1]   Go Up
Jump to: