s

Dependencies:   mbed

Fork of LAB08_Oppgave1 by EL-POM1001

Revision:
0:cf9946c35521
Child:
1:8717e146d58f
diff -r 000000000000 -r cf9946c35521 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Oct 21 09:50:57 2015 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+
+PwmOut pwmLed(PB_9);
+
+int main()
+{
+    pwmLed.period(0.020); // 20ms Periode tid
+        
+    //Set the led ouput duty-cycle to 1%
+    float brightness=0.01;
+    pwmLed=brightness;
+    
+    printf("Press 'u' to turn LED1 brightness up, 'd' for down\n\r");
+    while(1) {
+
+        char c = getchar();
+        if((c == 'u') && (brightness < 0.1f))
+            brightness += 0.001f;
+        if((c == 'd') && (brightness > 0.0f))
+            brightness -= 0.001f;
+
+        //Set the ouput duty-cycle, specified as a percentage
+        pwmLed = brightness;
+        printf("%c %1.3f \n \r",c,brightness);
+    }
+}
+