codigo:
/**************************************************************************
darus67
20 October 2007
**************************************************************************/
#include
#define FADE_RATE 20 // the larger this value, the slower
// the LED will fade
#define INITIAL_WIDTH 128 // the starting value of the PWM pulse
// this is about 50% pulse width
void fade(char bit){
/**************************************************************************
Use pulse width modulation to cause LEDs on Port B to fade out
LEDs corresponding to high bits in 'bit' will fade out
**************************************************************************/
unsigned char rate = FADE_RATE;
unsigned char pulse_width = INITIAL_WIDTH;
unsigned char count;
while(pulse_width){ // as long as pulse_width is non-zero
// loop through the PWM routine
PORTB |= bit; // turn on the LED
for(count=0; count
// the currently lit one
}
// scan from left to right, with the trailing LED fading out
for(b=0x40; b; b>>=1){ // We're shifting b right instead of left this time
PORTB = b; // turn on the LED
fade(b<<1);>