// Fade a led on. #include "mbed.h"PwmOut led(LED1);
int main() {
while(1) {
led = led + 0.01;
wait(0.2);
if(led == 1.0) {
led = 0;
}
}
}
Note:
On the LPC1768 and LPC2368, the PWMs all share the same period - if you change the period for one, you change it for all. Although routines that change the period maintain the duty cycle for its PWM, all other PWMs will require their duty cycle to be refreshed.
Return the current output duty-cycle setting, measured as a percentage (float)
Returns:
A floating-point value representing the current duty-cycle being output on the pin, measured as a percentage. The returned value will lie between 0.0f (representing on 0%) and 1.0f (representing on 100%).
Note:
This value may not match exactly the value set by a previous <write>.
Set the ouput duty-cycle, specified as a percentage (float)
Parameters:
value
A floating-point value representing the output duty-cycle, specified as a percentage. The value should lie between 0.0f (representing on 0%) and 1.0f (representing on 100%). Values outside this range will be saturated to 0.0f or 1.0f.
This site uses cookies to store information on your computer.
By continuing to use our site, you consent to our cookies.
If you are not happy with the use of these cookies, please review our
Cookie Policy
to learn how they can be disabled.
By disabling cookies, some features of the site will not work.
Access Warning
You do not have the correct permissions to perform this operation.