LED1 light use with PWM

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 PwmOut led(LED1);
00004 
00005 int main() {
00006     while(1) {
00007         for(float p = 0.0f; p < 0.5f; p += 0.01f) {
00008             led = p;
00009             wait(0.02);
00010         }
00011         for(float p = 0.49f; p > 0.0f; p -= 0.01f) {
00012             led = p;
00013             wait(0.02);
00014         }
00015         wait(0.5);
00016     }
00017 }