Arduino_Fade sample code ported.

Dependencies:   mbed

main.cpp

Committer:
homayoun
Date:
2014-09-03
Revision:
0:a594269e86ab

File content as of revision 0:a594269e86ab:

#include "mbed.h"

PwmOut led(LED1);

float brightness = 0.0f;    // how bright the LED is
float fadeAmount = 0.02f;    // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup()
{

}

void loop()
{
    brightness += fadeAmount;
    if (brightness <= 0.0f || brightness >= 1.0f) fadeAmount = -fadeAmount; // == doesn't work!!!
    led = brightness;
    wait(0.03);
}

int main()
{
    setup();
    while(1) loop();
}