Script voor aansturen motoren

Dependencies:   Encoder HIDScope MODSERIAL mbed-dsp mbed

Revision:
11:ba0a33e6ff0d
Parent:
10:a2a2e7bfdc86
Child:
12:795657e66960
--- a/main.cpp	Tue Oct 28 00:11:24 2014 +0000
+++ b/main.cpp	Tue Oct 28 00:22:43 2014 +0000
@@ -31,6 +31,9 @@
 PwmOut pwm_motor2(M1_PWM);
 DigitalOut motordir2(M1_DIR);
 
+float speed1;
+float hoek1; 
+
 bool flip=false;
 
 void attime()
@@ -69,19 +72,31 @@
 
 int main()
 {   
+    speed1 = 0.7; 
+    hoek1 = 0.09; //in seconde
     wait(1);
     pwm_motor1.period_us(100);
-    motordir1=0;
-    pwm_motor1.write(0.7);
-    wait(0.78);
+    motordir1=0;            //aangeven van directie
+    pwm_motor1.write(speed1);  //snelheid van de motor
+    wait(hoek1);             //Hierdoor kun je het aantal graden bepalen die de as draait
     pwm_motor1.write(0);
     wait(1);
     motordir1=1;
-    pwm_motor1.write(0.7);
-    wait(0.78);
+    pwm_motor1.write(speed1);
+    wait(hoek1);
     pwm_motor1.write(0);
     wait(1);
     motordir1=1;
+    pwm_motor1.write(speed1);
+    wait(hoek1);
+    pwm_motor1.write(0);
+    wait(1);
+    motordir1=0;
+    pwm_motor1.write(speed1);
+    wait(hoek1); 
+    pwm_motor1.write(0);
+    
+