PWM
 
Syntax

void PWM(int pin, int duty, int duration);


Description


Generate an analog signal on pin for milliseconds with a duty cycle of 0 to 255.
A duty cycle of 255 corresponds to an output value of 100%.

The IO direction of the pin will be set to output, the PWM pulse train is output, and then the pin is set to tristate (input).  If the pin is connected to an RC filter, then the voltage will stay on the capacitor for a period of time determined by the load.

Example

    printf("Ramp thru PWM on LED\n");
    for (i=0; i<256; i++) PWM (15,255-i,20); 


See also