Interrupt experiment

Dependencies:   mbed C12832

main.cpp

Committer:
AdamCiechalski
Date:
2019-04-13
Revision:
0:a8022529c815
Child:
1:1407e3388ad8

File content as of revision 0:a8022529c815:

#include "mbed.h"

Serial pc(USBTX, USBRX);
PwmOut led(LED1);

float brightness = 0.0;

int main() {
    pc.printf("Press '^' to turn LED1 brightness up, 'v' to turn it down\n");
        while(1) {
        char c = pc.getc();
        if((c == '^') && (brightness < 0.5)) {
            brightness += 0.01;
            led = brightness;
            }
            if((c == 'v') && (brightness > 0.0)) {
            brightness -= 0.01;
            led = brightness;
            }
        }
    }