Samenwerking Groep 12

Dependencies:   Encoder MODSERIAL HIDScope mbed

Foo

Revision:
8:a41b2d8f6e74
Parent:
7:b2b1d1c36861
Child:
9:0a7981d2da8a
diff -r b2b1d1c36861 -r a41b2d8f6e74 main.cpp
--- a/main.cpp	Mon Sep 21 11:37:40 2015 +0000
+++ b/main.cpp	Mon Sep 21 12:34:43 2015 +0000
@@ -8,7 +8,7 @@
 PwmOut motor2speed(D5);
 DigitalIn button(PTA4);
 Encoder motor2(D13,D12);
-MODSERIAL pc(USBTX,USBRX);
+MODSERIAL pc(USBTX,USBRX); 
 
 
 int main()
@@ -16,13 +16,13 @@
     pc.baud(9600);
     while(true) {
         if (button.read() < 0.5) {   //if button pressed
+            motor2.setPosition(0);
             motor2direction = 1;
-            motor2speed = 0.5f;
+            motor2speed = 0.5f;  
             pc.printf("positie = %d \r\n", motor2.getPosition());
         } else {                    // If button is not pressed
             motor2direction = 0;
             motor2speed = 0;
-            motor2.setPosition(0);
             pc.printf("positie = %d \r\n", motor2.getPosition());
         }
     }