![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
br g5
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
main.cpp
- Committer:
- boydmartherus
- Date:
- 2019-09-23
- Revision:
- 14:4342436f9f4f
- Parent:
- 12:597f6b8224e5
- Child:
- 15:49f750d895d7
File content as of revision 14:4342436f9f4f:
#include "mbed.h" #include "MODSERIAL.h"; #include "FastPWM.h" ; #include "QEI.h" ; #include "Motor.h" ; Serial pc(USBTX,USBRX); AnalogIn pot(PTB2); InterruptIn button(PTB3); FastPWM motor(D5); FastPWM led(PTA1); int pulses = 131; QEI wheel (D13,D12,NC,pulses); int pin = 1; void flip() { pin=!pin; } int main() { printf("Control with dial\n"); button.rise(&flip); while(true) { if (pin == 1) { printf("now forward"); led.write(pot); motor.write(pot); //printf("motor speeed is (%f)\n\r",pot.read()); //printf("pulse number is (%i)\n\r",wheel.getPulses()); } else { printf("now reversing"); led.write(1-pot); motor.write(pot); //printf("motor speeed is (%f)\n\r",pot.read()); //printf("pulse number is (%i)\n\r",wheel.getPulses()); } } }