project van rtos

Dependencies:   mbed-os

Fork of MFRC522 by Martin Olejar

Revision:
9:f1f71e42e267
Parent:
8:4638e3f14c41
Child:
10:65c046928e5d
--- a/main.cpp	Thu May 17 11:03:21 2018 +0000
+++ b/main.cpp	Thu May 17 11:53:09 2018 +0000
@@ -249,35 +249,37 @@
 
 void motorControl() {
     while(true) {
-        if (sensorValue != 0) {
             IN1 = 1;
             IN2 = 0;
             IN3 = 1;
             IN4 = 0;
             
-            Thread::wait(speedcontrol - speedcontrol/sensorValue);
+            //Thread::wait(speedcontrol - speedcontrol/sensorValue);
+            Thread::wait(100-100*sensorValue);
             
             IN1 = 1;
             IN2 = 0;
             IN3 = 0;
             IN4 = 1;
             
-            Thread::wait(speedcontrol - speedcontrol/sensorValue); 
+            //Thread::wait(speedcontrol - speedcontrol/sensorValue);
+            Thread::wait(100-100*sensorValue);
             
             IN1 = 0;
             IN2 = 1;
             IN3 = 0;
             IN4 = 1;
             
-            Thread::wait(speedcontrol - speedcontrol/sensorValue);
+            //Thread::wait(speedcontrol - speedcontrol/sensorValue);
+            Thread::wait(100-100*sensorValue);
             
             IN1 = 0;
             IN2 = 1;
             IN3 = 1;
             IN4 = 0;
             
-            Thread::wait(speedcontrol - speedcontrol/sensorValue);
-        }
+            //Thread::wait(speedcontrol - speedcontrol/sensorValue);
+            Thread::wait(100-100*sensorValue);
     }
 }
 
@@ -306,6 +308,7 @@
 
 void samplePotentio() {
     while (true) {
+        pc.printf("ik sample. %f ", sensorValue);
         float samples[20];
         float sum = 0;
         for(int i = 0; i < 20; i++) {
@@ -319,7 +322,10 @@
     }
 }
 
+
 void checkRFID() {
+  // Init. RC522 Chip
+  RfChip.PCD_Init();
   while (true) {  
 
     // Look for new cards
@@ -340,7 +346,7 @@
     pc.printf("Card UID: ");
     for (uint8_t i = 0; i < RfChip.uid.size; i++)
     {
-      pc.printf(" %X02", RfChip.uid.uidByte[i]);
+      pc.printf(" %X02 ", RfChip.uid.uidByte[i]);
     }
     pc.printf("\n\r");
 
@@ -371,9 +377,6 @@
   thread_rfid.start(checkRFID);
   // Set debug UART speed
   //pc.baud(115200);
-
-  // Init. RC522 Chip
-  RfChip.PCD_Init();
   
     dg0 = 0;
     dg1 = 0;