![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Testing 1 blue pill
Dependencies: mbed mbed-rtos TextLCD
Diff: Stepper_Motor/STEPPER_MOTOR.cpp
- Revision:
- 18:3523660f3930
- Parent:
- 17:68b3fdabe4c5
- Child:
- 19:384642f39496
--- a/Stepper_Motor/STEPPER_MOTOR.cpp Tue Feb 12 10:03:05 2019 +0000 +++ b/Stepper_Motor/STEPPER_MOTOR.cpp Tue Feb 12 10:12:08 2019 +0000 @@ -9,7 +9,10 @@ } STEPPER_MOTOR::~STEPPER_MOTOR(){} //Destructor - +float STEPPER_MOTOR::Get_Turns() +{ + return (_Steps_Done /50); +} void STEPPER_MOTOR::Rotate_Steps(int Steps) { #define STIME 1000 @@ -17,9 +20,9 @@ Steps = Steps*50; //int correctionfactor; //int timeofturn=correctinfactor*speed; - - int mystep=0; - printf("START!!! step value is=%d\n\r",mystep); + _Steps_Done = 0; + //int mystep=0; + //printf("START!!! step value is=%d\n\r",mystep); for(int x =0 ; x <= Steps; x++) { //printf("FOR LOOP! step value is=%d %d\n\r",mystep,x); @@ -27,29 +30,31 @@ this->pin2 = 1; this->pin3 = 0; this->pin4 = 1; - mystep=1; + //mystep=1; wait_us(1000); //printf("FOR LOOP! step value is=%d %d\n\r",mystep,x); this->pin1 = 0; this->pin2 = 1; this->pin3 = 1; this->pin4 = 0; - mystep=2; + //mystep=2; wait_us(1000); //printf("FOR LOOP! step value is=%d %d\n\r",mystep,x); this->pin1 = 1; this->pin2 = 0; this->pin3 = 1; this->pin4 = 0; - mystep=3; + //mystep=3; wait_us(1000); //printf("FOR LOOP! step value is=%d %d\n\r",mystep,x); this->pin1 = 1; this->pin2 = 0; this->pin3 = 0; this->pin4 = 1; - mystep=4; + //mystep=4; wait_us(1000); + + _Steps_Done = _Steps_Done +1; /* printf("FOR LOOP! step value is=%d %d\n\r",mystep,x); this->pin1 = 0; this->pin2 = 1;