mag niet van hendrik D:

Dependencies:   mbed MatrixMath QEI HIDScope Matrix biquadFilter MODSERIAL FastPWM

Files at this revision

API Documentation at this revision

Comitter:
Hendrikvg
Date:
Thu Sep 19 14:41:31 2019 +0000
Parent:
8:d1794f225fff
Child:
10:3a3d6373b41c
Child:
14:20f11bb58244
Commit message:
L3: Assignment 1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Sep 14 11:08:13 2019 +0000
+++ b/main.cpp	Thu Sep 19 14:41:31 2019 +0000
@@ -1,30 +1,41 @@
-#include "mbed.h"
-#include "MODSERIAL.h"
-#include "Callback.h"
+#include "mbed.h"
+
+Serial pc(USBTX,USBRX);
+InterruptIn BUT1(D1);
+InterruptIn BUT2(D0);
+PwmOut lichtje(D3);
+AnalogIn   ain(A0);
 
-MODSERIAL pc(USBTX, USBRX);
-DigitalOut ledr(LED_RED);
-InterruptIn sw2(SW2);
+float getal;
+int n=5;
 
-int n = 0;
-
-void flash()
+void plus()
+{
+    n++; // n=n+1
+    if (n>10){
+        n=10;
+        }
+    }
+    
+void min()
 {
-    n++;
-    pc.printf("The LED is now going to flash %i times.\n\r",n);
-    for (int i = 0; i < n; i++) {
-        ledr = 0;
-        wait_ms(50);
-        ledr = 1;
-        wait_ms(200);
+    n--;
+    if (n<0){
+        n=0;
+        }
     }
-}
 
-int main()
-{
+int main() {
     pc.baud(115200);
-    ledr = 1;
-    sw2.fall(flash);
-    while(1) {
-    }
+    lichtje=1;
+    BUT1.fall(plus);
+    BUT2.fall(min);
+        while(true)
+            {
+                    getal = 0.01*n*ain.read();
+                   lichtje.period(4.0f);  // 4 second period
+                    lichtje.write(getal);  // duty cycle
+                    pc.printf("%3.3f%\n\r", ain.read());
+        
+    }
 }
\ No newline at end of file