For Hamza

Dependencies:   StepperMotorUni StepperMotorUni_Hello mbed

Fork of StepperMotorUni_Hello by Tedd OKANO

Files at this revision

API Documentation at this revision

Comitter:
poupalov
Date:
Wed Feb 22 12:49:52 2017 +0000
Parent:
1:80c512ccd0f2
Commit message:
O_O

Changed in this revision

StepperMotorUni_Hello.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 80c512ccd0f2 -r 21d312d28d45 StepperMotorUni_Hello.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/StepperMotorUni_Hello.lib	Wed Feb 22 12:49:52 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/okano/code/StepperMotorUni_Hello/#80c512ccd0f2
diff -r 80c512ccd0f2 -r 21d312d28d45 main.cpp
--- a/main.cpp	Wed Apr 22 03:26:01 2015 +0000
+++ b/main.cpp	Wed Feb 22 12:49:52 2017 +0000
@@ -1,27 +1,56 @@
-/** "Hello" program for StepperMotorUni class library
- *
- *  very simple sample of "StepperMotorUni" operation 
- * 
- *  version 1.0
- *  copyright: 2014 Tedd OKANO
- *  released under the Apache 2 license License
- */
-
 #include "mbed.h"
 #include "StepperMotorUni.h"
 
+int nombreDePas;
+double rayonCylindre;
+double rayonRoue;
+double rho = rayonCylindre / rayonRoue;
+int k = floor((rho*nombreDePas) / 12);
+
+int bleu;
+int blanc;
+int jaune;
+int nouveau;
+int notreCouleur;
+int periode;
+
+
+
 StepperMotorUni motor( p26, p25, p24, p23 );
+int mask;
+PortIn p(capteur,mask);
 
 int main()
 {
     motor.set_operation_phase_mode( StepperMotorUni::HALFSTEP );
     motor.set_pps( 200 );
+    
+    int i = 0;
+    boolean pasfini = false;
+    while (true) {
+        int couleur = p.read();
+        if(couleur == nouveau){
+            pasfini = true;
+            i = 0;
+        }
+        if(pasfini){
+            if(couleur != notreCouleur && i==0){
+                motor.move_steps( k );
+            }
+            else if(couleur != notreCouleur && i!=0){
+                motor.move_steps( (-2)*k );
+                pasfini = false;
+            }
+            else if(couleur == notreCouleur && i==0){
+                i+=1;
+                motor.move_steps( k );
+            }
+        }
+        
+        wait(periode);
+        }
+            
+        }     
 
-    while ( 1 ) {
-        motor.move_steps( 48 );
-        wait( 1 );
-
-        motor.move_steps( -48 );
-        wait( 1 );
     }
 }