mooi spul

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
joosthartkamp
Date:
Wed May 03 09:54:02 2017 +0000
Commit message:
mooi spul

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
diff -r 000000000000 -r 29223e7b313d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 03 09:54:02 2017 +0000
@@ -0,0 +1,88 @@
+#include "mbed.h"
+
+Ticker lidar;
+Ticker serial;
+
+Serial pc(USBTX, USBRX);
+
+DigitalOut led1(LED1);
+DigitalOut steppera (D2);
+DigitalOut stepperb (D3);
+DigitalOut stepperc (D4);
+DigitalOut stepperd (D5);
+
+int stapmode = 0;
+int position = 0;
+int pos;
+
+// poar neemn
+// twee poar neemn
+// twee tettn in n envelop
+
+int stepper(int stapmode)
+{
+    switch (stapmode) {
+        case 0:
+            steppera = 1;
+            stepperb = 0;
+            stepperc = 1;
+            stepperd = 0;
+            pos ++;
+            break;
+        case 1:
+            steppera = 1;
+            stepperb = 0;
+            stepperc = 0;
+            stepperd = 1;
+            pos ++;
+            break;
+        case 2:
+            steppera = 0;
+            stepperb = 1;
+            stepperc = 0;
+            stepperd = 1;
+            pos ++;
+            break;
+        case 3:
+            steppera = 0;
+            stepperb = 1;
+            stepperc = 1;
+            stepperd = 0;
+            pos ++;
+            break;
+            ;
+    }
+    if (pos > 360) {
+            pos = 0;
+            }
+    return pos;
+    
+}
+
+void run_serial()  //deze functie word periodiek aangeroepen om de stappenmotor te draaien en de afstand te meten
+{
+    
+    pc.printf("%d\n",position);
+}
+
+void run_lidar()  //deze functie word periodiek aangeroepen om de stappenmotor te draaien en de afstand te meten
+{
+    stapmode ++;
+    if (stapmode > 3) {
+        stapmode = 0;
+    }
+    position = stepper(stapmode);
+}
+
+int main()
+{
+    lidar.attach(&run_lidar, 0.0001);
+    serial.attach(&run_serial, 0.2);
+    while (true) {
+        //doe maar wat leuks
+        led1 = !led1;
+        wait_ms (500);
+    }
+
+
+}
\ No newline at end of file
diff -r 000000000000 -r 29223e7b313d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed May 03 09:54:02 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/794e51388b66
\ No newline at end of file