s

Dependencies:   mbed

Fork of LAB08_Oppgave1 by EL-POM1001

main.cpp

Committer:
rlanghbv
Date:
2015-10-21
Revision:
0:cf9946c35521
Child:
1:8717e146d58f

File content as of revision 0:cf9946c35521:

#include "mbed.h"

PwmOut pwmLed(PB_9);

int main()
{
    pwmLed.period(0.020); // 20ms Periode tid
        
    //Set the led ouput duty-cycle to 1%
    float brightness=0.01;
    pwmLed=brightness;
    
    printf("Press 'u' to turn LED1 brightness up, 'd' for down\n\r");
    while(1) {

        char c = getchar();
        if((c == 'u') && (brightness < 0.1f))
            brightness += 0.001f;
        if((c == 'd') && (brightness > 0.0f))
            brightness -= 0.001f;

        //Set the ouput duty-cycle, specified as a percentage
        pwmLed = brightness;
        printf("%c %1.3f \n \r",c,brightness);
    }
}