![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Control up to two motors using filtered EMG signals and a PID controller
Dependencies: FastPWM HIDScope MODSERIAL QEI Matrix biquadFilter controller errorFetch mbed motorConfig refGen MatrixMath inverseKinematics
Fork of Minor_test_serial by
main.cpp@4:f74c981d9bc0, 2017-09-12 (annotated)
- Committer:
- tvlogman
- Date:
- Tue Sep 12 15:15:24 2017 +0000
- Revision:
- 4:f74c981d9bc0
- Parent:
- 3:99a568200720
- Child:
- 5:d396168a1b20
Added functionality to turn on various color LEDs when corresponding keys are pressed.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vsluiter | 0:c8f15874531b | 1 | #include "mbed.h" |
vsluiter | 0:c8f15874531b | 2 | #include "MODSERIAL.h" |
vsluiter | 0:c8f15874531b | 3 | |
tvlogman | 3:99a568200720 | 4 | DigitalOut ledG(LED_GREEN); |
tvlogman | 3:99a568200720 | 5 | DigitalOut ledR(LED_RED); |
tvlogman | 3:99a568200720 | 6 | DigitalOut ledB(LED_BLUE); |
vsluiter | 0:c8f15874531b | 7 | MODSERIAL pc(USBTX, USBRX); |
vsluiter | 0:c8f15874531b | 8 | |
vsluiter | 0:c8f15874531b | 9 | int main() |
vsluiter | 0:c8f15874531b | 10 | { |
tvlogman | 2:002f6b69ebaf | 11 | //int i = 0; |
vsluiter | 0:c8f15874531b | 12 | pc.baud(115200); |
Gijsvanoort | 1:40470bc517f1 | 13 | pc.printf("Hello World!\r\n"); |
vsluiter | 0:c8f15874531b | 14 | |
tvlogman | 3:99a568200720 | 15 | ledR = true; |
tvlogman | 3:99a568200720 | 16 | ledB = true; |
tvlogman | 4:f74c981d9bc0 | 17 | ledG = true; |
tvlogman | 3:99a568200720 | 18 | |
vsluiter | 0:c8f15874531b | 19 | while (true) { |
tvlogman | 3:99a568200720 | 20 | int keyPress = pc.getc(); |
tvlogman | 3:99a568200720 | 21 | pc.putc(keyPress); |
tvlogman | 4:f74c981d9bc0 | 22 | pc.printf("%i", keyPress); |
tvlogman | 4:f74c981d9bc0 | 23 | |
tvlogman | 4:f74c981d9bc0 | 24 | if(keyPress == 114) |
tvlogman | 4:f74c981d9bc0 | 25 | { |
tvlogman | 4:f74c981d9bc0 | 26 | ledG = true; |
tvlogman | 4:f74c981d9bc0 | 27 | ledB = true; |
tvlogman | 4:f74c981d9bc0 | 28 | ledR = !ledR; |
tvlogman | 4:f74c981d9bc0 | 29 | } |
tvlogman | 4:f74c981d9bc0 | 30 | else if(keyPress == 103) |
tvlogman | 4:f74c981d9bc0 | 31 | { |
tvlogman | 4:f74c981d9bc0 | 32 | ledR = true; |
tvlogman | 4:f74c981d9bc0 | 33 | ledB = true; |
tvlogman | 4:f74c981d9bc0 | 34 | ledG = !ledG; |
tvlogman | 4:f74c981d9bc0 | 35 | } |
tvlogman | 4:f74c981d9bc0 | 36 | else if(keyPress == 98) |
tvlogman | 4:f74c981d9bc0 | 37 | { |
tvlogman | 4:f74c981d9bc0 | 38 | ledR = true; |
tvlogman | 4:f74c981d9bc0 | 39 | ledG = true; |
tvlogman | 4:f74c981d9bc0 | 40 | ledB = !ledB; |
tvlogman | 4:f74c981d9bc0 | 41 | } |
tvlogman | 4:f74c981d9bc0 | 42 | else |
tvlogman | 4:f74c981d9bc0 | 43 | { |
tvlogman | 4:f74c981d9bc0 | 44 | ledG = true; |
tvlogman | 4:f74c981d9bc0 | 45 | ledB = true; |
tvlogman | 4:f74c981d9bc0 | 46 | ledR = true; |
tvlogman | 4:f74c981d9bc0 | 47 | } |
tvlogman | 2:002f6b69ebaf | 48 | |
vsluiter | 0:c8f15874531b | 49 | } |
vsluiter | 0:c8f15874531b | 50 | } |