Intensidad_Led

Dependencies:   mbed

main.cpp

Committer:
fpachays
Date:
2020-02-08
Revision:
0:5248e12b2868

File content as of revision 0:5248e12b2868:

#include "mbed.h"
Serial pc(PA_2, PA_3,115200); //tx, rx
PwmOut led(PA_0);
float brightness=0.0;

int main()
{
    pc.printf("control of LED dimmer by host terminal\n\r");
    pc.printf("Press 'u' = brighter, 'd' = dimmer\n\r");
    while (1) {
        char c = pc.getc();
        wait(0.001);
        if((c == 'u') && (brightness < 1)) {
            brightness += 0.1;
            motor= brightness;
        }
        if(( c == 'd') && (brightness > 0)) {
            brightness -= 0.1;
            motor = brightness;
        }

        pc.printf("%c %1.3f \n \r",c,brightness);

    }
}