
Interrupt experiment
Diff: main.cpp
- Revision:
- 0:a8022529c815
- Child:
- 1:1407e3388ad8
diff -r 000000000000 -r a8022529c815 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Apr 13 13:21:20 2019 +0000 @@ -0,0 +1,21 @@ +#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; + } + } + } \ No newline at end of file