Bernd Eisenberger
/
TINF_003_PWM
One LED switching between 50 and 100% PWM with one button.
Homepage
Switching PWM¶
TINF_003_PWM
#include "mbed.h" PwmOut led(D5); DigitalIn btn(D6); int main() { btn.mode(PullDown); led=0.5; while(1) { if(btn == 1) { wait_ms(200); if(led==1.0&&btn==1) { wait_ms(500); led=0.5; } if(led==0.5&&btn==1) { wait_ms(500); led=1.0; } } }}