Teaching Assistant / Mbed 2 deprecated 201LED_dimmer

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
302Instructor
Date:
Thu Jan 22 19:55:25 2015 +0000
Commit message:
1/22/2015

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	Thu Jan 22 19:55:25 2015 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+ 
+Serial pc(USBTX, USBRX);
+PwmOut led(LED1);
+ 
+float brightness = 0.0;
+ 
+int main() {
+    pc.printf("Press '+' to turn LED1 brightness up, '-' to turn it down \n\r");
+    led.period(0.02);
+    while(1) {
+        char c = pc.getc();
+        if ((c == '+') && (brightness > 0.0)) {
+            brightness -= 0.1;
+            led.write(brightness);
+            printf("%f",brightness);
+            printf("\n\rUP");
+        }
+        if ((c == '-') && (brightness < 0.999)) {
+            brightness += 0.1;
+            led.write(brightness);
+            printf("%f",brightness);
+            printf("\n\rDOWN");
+        }
+    }
+}
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jan 22 19:55:25 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89
\ No newline at end of file