serial dimmer demo using serial interface based on :https://mbed.org/handbook/SerialPC example with minor modifications

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
felipeM
Date:
Sat Oct 05 19:30:05 2013 +0000
Commit message:
serial controlled dimmer demo; taken from (with minor modifications) ; https://mbed.org/handbook/SerialPC

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Oct 05 19:30:05 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file