yellow bee
/
Nucleo_blink_led1
test1
Fork of Nucleo_blink_led by
Diff: main.cpp
- Revision:
- 0:9d596b5ec030
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Sep 06 07:40:21 2016 +0000 @@ -0,0 +1,57 @@ +#include "mbed.h" + + +/* +DigitalOut myled(LED1); + +int main() +{ + while(1) { + myled = 1; // LED is ON + wait(0.2); // 200 ms + myled = 0; // LED is OFF + wait(1.0); // 1 sec + } +} + + +Serial pc(USBTX, USBRX); // tx, rx + +int main() { + pc.printf("Hello World!\n"); + while(1); +} + + + +Serial pc(USBTX, USBRX); + +int main() { + pc.printf("Echoes back to the screen anything you type\n"); + while(1) { + pc.putc(pc.getc()); + } +} + +*/ + +Serial pc(USBTX, USBRX); // tx, rx +PwmOut led(LED1); + +float brightness = 0.0; + +int main() { + pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\n"); + + while(1) { + char c = pc.getc(); + if((c == 'u') && (brightness < 0.5)) { + brightness += 0.01; + led = brightness; + } + if((c == 'd') && (brightness > 0.0)) { + brightness -= 0.01; + led = brightness; + } + } +} \ No newline at end of file