mencari respon motor launcher dengan fungsi step

Dependencies:   Motor mbed millis

main.cpp

Committer:
Najib_irvani
Date:
2017-02-16
Revision:
0:be14d75c8037
Child:
1:3a234ff1442b

File content as of revision 0:be14d75c8037:

#include "mbed.h"
#include "encoderKRAI.h"
#include "Motor.h"
#include "millis.h"
 
encoderKRAI encoder( PB_13, PB_14, 14, encoderKRAI::X2_ENCODING);
Serial pc(USBTX,USBRX);
Motor motor(PA_8,PC_1,PC_2);

unsigned long int previousMillis = 0;
unsigned long int currentMillis;
double rpm;
 


int main() {

startMillis();    
motor.speed(0.5);
    
    while(1) {

        currentMillis = millis();
        
        
        if (currentMillis-previousMillis>=100)
        {
            rpm = (double)encoder.getPulses();

            

        
            encoder.reset();
            pc.printf("%.04lf\n",rpm);
            
            previousMillis = currentMillis;
            
        }

        
        
    }
}