Dependencies:   mbed

main.cpp

Committer:
annodomini2
Date:
2009-11-26
Revision:
0:5b52db367115

File content as of revision 0:5b52db367115:

#include "mbed.h"

PwmOut myled(LED1);

bool back = false;
float drive = 0;

Timer timer;

int main() 
{
    int start = 0;
    int current = 0;
    
    timer.start();
    
    myled = 1.0;
    
    while(1) 
    {
        current = timer.read_ms();
    
        if((current - start) >= 10)
        {
            if(back)
            {
                drive -= 0.01;
                
                if(drive <= 0)
                {
                    drive = 0;
                    back = false;
                }
            }
            else
            {
                drive += 0.01;
                
                if(drive >= 1)
                {
                    drive = 0.999;
                    back = true;
                }
            }
    
            myled = drive;
            start = timer.read_ms();
        }
    }
}