Changing Intensity of LEDs (Pulse width Modulation)

Dependencies:   mbed

main.cpp

Committer:
div1104
Date:
2021-01-23
Revision:
0:9e6c3bedd569

File content as of revision 0:9e6c3bedd569:

#include "mbed.h"

PwmOut myled(LED1);

int main() 
{
    while(1) 
    {
       for(float i=1;i>=0;i=i-0.1)
        {
         myled = i;
         wait(0.5);
        }
        for(float i=0;i<=1;i=i+0.1)
        {
         myled = i;
         wait(0.2);
        }
    }
}