encoder verwerkt
Dependencies: MODSERIAL QEI mbed
Fork of motor_control by
main.cpp
- Committer:
- daniQQue
- Date:
- 2016-09-30
- Revision:
- 4:d39f84608204
- Parent:
- 3:a50f2ce05e1f
- Child:
- 5:bb97950558bd
File content as of revision 4:d39f84608204:
#include "mbed.h" //standaard bieb mbed #include "QEI.h" //bieb voor encoderfuncties in c++ #include "MODSERIAL.h" //bieb voor modserial //alle ingangen definieren DigitalIn encoder1A(D13); DigitalIn encoder1B(D12); DigitalIn button(D11); DigitalOut led(D10); DigitalOut motor1(D4); PwmOut pwm_motor1(D5); MODSERIAL pc(USBTX, USBRX); //constanten const int CW = 0; //definitie rechtsom 'lage waarde' const int CCW =2.5; //definitie linksom 'hoge waarde' //programma int main () { pc.baud(115200); //contact maken met computer volatile int counts; while(true) { if (button==1) { //als knop is aan dan led=1; motor1= CCW; pwm_motor1=2.5; QEI Encoder(D12,D13,NC,64); counts = Encoder.getPulses(); pc.printf("encoder counts %i", counts); } else{ led=!led; pwm_motor1=0; } } }