0
\$\begingroup\$

I have 8 leds in a line, and a PIC microcontroller with 8 free digital outputs and one free pwm output.

I need to control the leds in a way that at first they are all on, then the rightmost begins to fade to zero, once it reaches zero it stays off and the seventh begins to fade and so on untill all are off.

Can this be done using only 8 outputs and a PWM?

I thought to power the leds directly with the output, wether they are on or off, and to use the pwm with diodes to PWM the turned off leds. Problem is that with this solution all the off led's turn on by the pwm.. I need only the very last one to be fading.

Can this be done using only very basic components like diodes, and similar?

Thanks

\$\endgroup\$
0
\$\begingroup\$

If you have a micro controller driving 8 LEDs you would normally not need any extra components. (The exception would be if your controller is so busy that it does not have spare cycles to control the LEDs. But then you probably have chosen the wrong controller).

You can make a PWM in software and got through a loop too drive the pins one after the other. Because the eye is slow a PWM at e.g. 100 Hz would suffice. (But I would try to go for even higher e.g. 200 Hz).

\$\endgroup\$
0
\$\begingroup\$

You can do this by an 8-bit shift register and a clock either by a 555 timer or manually using a delayed, debouched push button to turn off one led once at a time. The shift register has initially 1's in it (meaning all leds are on). The leds are connected to the output pins of the register, each through a current limiting resistor.

enter image description here

A typical 8-bit shift register is 74HC595. You can read more about the pinouts from the datasheet. For this simple circuit you need to first set Data pin to 1 and let the Shift Register Clock (SRCLK) run for at least 8 periods of the clock so that it stores all ones into it. At this time the leds are all on and you can set Data pin to 0. Since it's positive-edge triggered you can turn off one led at each rising edge of the SRCLK. Do this for 8 times until all leds fade off.

You can initially set the Storage Register Clock (RCLK) to low when presetting the register, and once it's done make it high. This prevents from seeing the leds turning on during the initial setting.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.