pot controller voor positie, kp handmatig instellen, werkt met motor 1 en 2

Dependencies:   MODSERIAL QEI mbed-dsp mbed

Fork of PI_controller_verbeteringen by ProjectGroep23

Revision:
2:52b3c0b95388
Parent:
1:40470bc517f1
Child:
3:40a25c2c24ba
--- a/main.cpp	Mon Sep 11 10:42:39 2017 +0000
+++ b/main.cpp	Wed Sep 12 10:27:38 2018 +0000
@@ -1,19 +1,81 @@
 #include "mbed.h"
 #include "MODSERIAL.h"
 
-DigitalOut myled(LED_GREEN);
+Ticker Blinker;
+
+DigitalOut ledr(LED_RED);
+DigitalOut ledg(LED_GREEN);
+DigitalOut ledb(LED_BLUE);
+DigitalIn   sw2(PTC6);
+
 MODSERIAL pc(USBTX, USBRX);
 
+volatile char c;
+volatile char  color;
+
+void ButtonpressCheck()
+{    
+    if (c == 'r')
+    {
+        color = 'r';
+    }
+    else if (c == 'g')
+    {
+        color = 'g';        
+    }
+    else if (c == 'b')
+    {
+        color = 'b';
+    }
+    else
+    {
+        pc.printf("Character %c is not valid \r\n",c);
+        c = color;
+    }     
+    
+    if (color == 'r')
+    {
+        ledr = !ledr;
+        ledg = 1;
+        ledb = 1;
+    }
+    else if (color == 'g')
+    {
+        ledr = 1;
+        ledg = !ledg;
+        ledb = 1;
+    }
+    else if (color == 'b')
+    {
+        ledr = 1;
+        ledg = 1;
+        ledb = !ledb;
+    }
+    wait(0.25f);
+    ledr = 1;
+    ledg = 1;
+    ledb = 1;
+       
+}
+
 int main()
 {
-    int i = 0;
+    ledr = 1;
+    ledg = 1;
+    ledb = 1;
+    
+    pc.printf("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ~~~Pu$$Y~~~ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n");
+    
     pc.baud(115200);
-    pc.printf("Hello World!\r\n");
+    Blinker.attach(ButtonpressCheck, 0.5);
+    
     
-    while (true) {
-        wait(0.5f); // wait a small period of time
-        pc.printf("%d \r\n", i); // print the value of variable i
-        i++; // increment the variable
-        myled = !myled; // toggle a led
+    
+    while (true)
+    {
+        c = pc.getc();
     }
+    
 }
+
+