statemachine
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
main.cpp@9:cdcf30051100, 2019-09-20 (annotated)
- Committer:
- boydmartherus
- Date:
- Fri Sep 20 11:48:08 2019 +0000
- Revision:
- 9:cdcf30051100
- Parent:
- 7:d5e07647dfea
- Child:
- 10:9101c7a4f219
enkel motorspeed + led
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 | 7:d5e07647dfea | 5 | |
boydmartherus | 7:d5e07647dfea | 6 | Serial pc(USBTX,USBRX); |
boydmartherus | 7:d5e07647dfea | 7 | |
boydmartherus | 7:d5e07647dfea | 8 | InterruptIn button1(PTC2); |
boydmartherus | 7:d5e07647dfea | 9 | InterruptIn button2(PTC3); |
boydmartherus | 7:d5e07647dfea | 10 | InterruptIn button3(PTA4); |
boydmartherus | 7:d5e07647dfea | 11 | InterruptIn button4(PTC6); |
Mortimerz | 3:ea5f67f11825 | 12 | |
Mortimerz | 3:ea5f67f11825 | 13 | AnalogIn pot(PTB2); |
boydmartherus | 6:c2608dedfd70 | 14 | |
boydmartherus | 6:c2608dedfd70 | 15 | FastPWM motor(D5); |
boydmartherus | 9:cdcf30051100 | 16 | FastPWM led(PTA1); |
boydmartherus | 9:cdcf30051100 | 17 | DigitalOut richting(D4); |
boydmartherus | 9:cdcf30051100 | 18 | |
boydmartherus | 9:cdcf30051100 | 19 | int direction = 0; |
boydmartherus | 9:cdcf30051100 | 20 | void flip() { |
boydmartherus | 9:cdcf30051100 | 21 | direction = !direction; |
boydmartherus | 9:cdcf30051100 | 22 | } |
MarliesWeggemans | 4:3e9a8f5d9a1a | 23 | |
Mortimerz | 3:ea5f67f11825 | 24 | int main(){ |
boydmartherus | 7:d5e07647dfea | 25 | printf("Controll with dial\n"); |
boydmartherus | 9:cdcf30051100 | 26 | |
boydmartherus | 9:cdcf30051100 | 27 | button2.rise(&flip); |
boydmartherus | 9:cdcf30051100 | 28 | |
boydmartherus | 9:cdcf30051100 | 29 | while(true) |
boydmartherus | 9:cdcf30051100 | 30 | { |
boydmartherus | 7:d5e07647dfea | 31 | wait(0.1); |
boydmartherus | 9:cdcf30051100 | 32 | printf("motor speed is (%f)\n\r",pot.read()); |
boydmartherus | 9:cdcf30051100 | 33 | wait(0.1); |
boydmartherus | 9:cdcf30051100 | 34 | richting.write(direction); |
boydmartherus | 9:cdcf30051100 | 35 | led.write(pot); |
boydmartherus | 7:d5e07647dfea | 36 | motor.write(pot); |
boydmartherus | 7:d5e07647dfea | 37 | } |
boydmartherus | 9:cdcf30051100 | 38 | } |