serial dimmer demo using serial interface based on :https://mbed.org/handbook/SerialPC example with minor modifications
Diff: main.cpp
- Revision:
- 0:623f6e1e1e89
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Oct 05 19:30:05 2013 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); // tx, rx +PwmOut r (LED_RED); + +float brightness = 0.25; + +int main() { + + r.period(0.001); + + pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\n"); + + while(1) { + char c = pc.getc(); + if((c == 'd') && (brightness < 1)) { + brightness += 0.01; + r = brightness; + } + if((c == 'u') && (brightness > 0.0)) { + brightness -= 0.01; + r = brightness; + } + + } +} \ No newline at end of file