br g5
Dependencies: mbed QEI HIDScope Motor biquadFilter MODSERIAL FastPWM
main.cpp@12:597f6b8224e5, 2019-09-20 (annotated)
- Committer:
- boydmartherus
- Date:
- Fri Sep 20 13:02:15 2019 +0000
- Revision:
- 12:597f6b8224e5
- Parent:
- 11:5171ac607099
motor + pulse + flip !!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RobertoO | 0:67c50348f842 | 1 | #include "mbed.h" |
Mortimerz | 3:ea5f67f11825 | 2 | #include "MODSERIAL.h"; |
Mortimerz | 3:ea5f67f11825 | 3 | #include "FastPWM.h" ; |
boydmartherus | 9:cdcf30051100 | 4 | #include "QEI.h" ; |
boydmartherus | 11:5171ac607099 | 5 | #include "Motor.h" ; |
boydmartherus | 7:d5e07647dfea | 6 | |
boydmartherus | 7:d5e07647dfea | 7 | Serial pc(USBTX,USBRX); |
boydmartherus | 7:d5e07647dfea | 8 | |
Mortimerz | 3:ea5f67f11825 | 9 | AnalogIn pot(PTB2); |
boydmartherus | 11:5171ac607099 | 10 | InterruptIn button(PTB3); |
boydmartherus | 6:c2608dedfd70 | 11 | |
boydmartherus | 6:c2608dedfd70 | 12 | FastPWM motor(D5); |
boydmartherus | 9:cdcf30051100 | 13 | FastPWM led(PTA1); |
boydmartherus | 10:9101c7a4f219 | 14 | |
boydmartherus | 10:9101c7a4f219 | 15 | int pulses = 131; |
boydmartherus | 10:9101c7a4f219 | 16 | QEI wheel (D13,D12,NC,pulses); |
MarliesWeggemans | 4:3e9a8f5d9a1a | 17 | |
boydmartherus | 12:597f6b8224e5 | 18 | int pin = 1; |
boydmartherus | 11:5171ac607099 | 19 | |
boydmartherus | 11:5171ac607099 | 20 | void flip() |
boydmartherus | 11:5171ac607099 | 21 | { |
boydmartherus | 11:5171ac607099 | 22 | pin=!pin; |
boydmartherus | 11:5171ac607099 | 23 | } |
boydmartherus | 11:5171ac607099 | 24 | |
boydmartherus | 11:5171ac607099 | 25 | |
boydmartherus | 10:9101c7a4f219 | 26 | int main() |
boydmartherus | 10:9101c7a4f219 | 27 | { |
boydmartherus | 11:5171ac607099 | 28 | printf("Control with dial\n"); |
boydmartherus | 11:5171ac607099 | 29 | button.rise(&flip); |
boydmartherus | 11:5171ac607099 | 30 | while(true) |
boydmartherus | 11:5171ac607099 | 31 | { |
boydmartherus | 11:5171ac607099 | 32 | if (pin == 1) |
boydmartherus | 11:5171ac607099 | 33 | { |
boydmartherus | 10:9101c7a4f219 | 34 | led.write(pot); |
boydmartherus | 12:597f6b8224e5 | 35 | wait(0.1); |
boydmartherus | 10:9101c7a4f219 | 36 | motor.write(pot); |
boydmartherus | 12:597f6b8224e5 | 37 | //printf("motor speeed is (%f)\n\r",pot.read()); |
boydmartherus | 12:597f6b8224e5 | 38 | //printf("pulse number is (%i)\n\r",wheel.getPulses()); |
boydmartherus | 11:5171ac607099 | 39 | } |
boydmartherus | 11:5171ac607099 | 40 | else |
boydmartherus | 11:5171ac607099 | 41 | { |
boydmartherus | 12:597f6b8224e5 | 42 | led.write(1-pot); |
boydmartherus | 12:597f6b8224e5 | 43 | wait(0.1); |
boydmartherus | 11:5171ac607099 | 44 | motor.write(-pot); |
boydmartherus | 12:597f6b8224e5 | 45 | //printf("motor speeed is (%f)\n\r",pot.read()); |
boydmartherus | 12:597f6b8224e5 | 46 | //printf("pulse number is (%i)\n\r",wheel.getPulses()); |
boydmartherus | 11:5171ac607099 | 47 | } |
boydmartherus | 11:5171ac607099 | 48 | } |
boydmartherus | 10:9101c7a4f219 | 49 | } |