For Hamza
Dependencies: StepperMotorUni StepperMotorUni_Hello mbed
Fork of StepperMotorUni_Hello by
main.cpp
- Committer:
- poupalov
- Date:
- 2017-02-22
- Revision:
- 2:21d312d28d45
- Parent:
- 1:80c512ccd0f2
File content as of revision 2:21d312d28d45:
#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); } } } }