Intensidad_Led

Dependencies:   mbed

Revision:
0:5248e12b2868
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 08 02:48:22 2020 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+Serial pc(PA_2, PA_3,115200); //tx, rx
+PwmOut led(PA_0);
+float brightness=0.0;
+
+int main()
+{
+    pc.printf("control of LED dimmer by host terminal\n\r");
+    pc.printf("Press 'u' = brighter, 'd' = dimmer\n\r");
+    while (1) {
+        char c = pc.getc();
+        wait(0.001);
+        if((c == 'u') && (brightness < 1)) {
+            brightness += 0.1;
+            motor= brightness;
+        }
+        if(( c == 'd') && (brightness > 0)) {
+            brightness -= 0.1;
+            motor = brightness;
+        }
+
+        pc.printf("%c %1.3f \n \r",c,brightness);
+
+    }
+}
+