Robert Schulte
/
frdm_MotorTryout
Motor tryout, nog niet volledigwerkend.
main.cpp@0:97d039743c1c, 2015-09-19 (annotated)
- Committer:
- Rvs94
- Date:
- Sat Sep 19 10:06:45 2015 +0000
- Revision:
- 0:97d039743c1c
Switchstatement toegevoegd, maar krijg m niet werkend.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rvs94 | 0:97d039743c1c | 1 | #include "mbed.h" |
Rvs94 | 0:97d039743c1c | 2 | #include "HIDScope.h" |
Rvs94 | 0:97d039743c1c | 3 | |
Rvs94 | 0:97d039743c1c | 4 | DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield) |
Rvs94 | 0:97d039743c1c | 5 | PwmOut motor2speed(D5); |
Rvs94 | 0:97d039743c1c | 6 | DigitalOut motor1direction(D7); //D6 en D7 voor motor 1 (op het motorshield) |
Rvs94 | 0:97d039743c1c | 7 | PwmOut motor1speed(D6); |
Rvs94 | 0:97d039743c1c | 8 | DigitalOut led(LED1); |
Rvs94 | 0:97d039743c1c | 9 | Serial pc(USBTX,USBRX); |
Rvs94 | 0:97d039743c1c | 10 | |
Rvs94 | 0:97d039743c1c | 11 | int main() |
Rvs94 | 0:97d039743c1c | 12 | { |
Rvs94 | 0:97d039743c1c | 13 | |
Rvs94 | 0:97d039743c1c | 14 | pc.baud(9600); |
Rvs94 | 0:97d039743c1c | 15 | char c = pc.getc(); |
Rvs94 | 0:97d039743c1c | 16 | while(true) |
Rvs94 | 0:97d039743c1c | 17 | { |
Rvs94 | 0:97d039743c1c | 18 | switch(c) |
Rvs94 | 0:97d039743c1c | 19 | { |
Rvs94 | 0:97d039743c1c | 20 | case 'r': |
Rvs94 | 0:97d039743c1c | 21 | motor2direction = 1; |
Rvs94 | 0:97d039743c1c | 22 | motor2speed = 0.5f; |
Rvs94 | 0:97d039743c1c | 23 | led = 0; |
Rvs94 | 0:97d039743c1c | 24 | wait(0.5f); |
Rvs94 | 0:97d039743c1c | 25 | pc.printf("R\n"); |
Rvs94 | 0:97d039743c1c | 26 | break; |
Rvs94 | 0:97d039743c1c | 27 | |
Rvs94 | 0:97d039743c1c | 28 | case 't': |
Rvs94 | 0:97d039743c1c | 29 | motor2direction = 0; |
Rvs94 | 0:97d039743c1c | 30 | motor2speed = 0.5f; |
Rvs94 | 0:97d039743c1c | 31 | led = 0; |
Rvs94 | 0:97d039743c1c | 32 | wait(0.5f); |
Rvs94 | 0:97d039743c1c | 33 | pc.printf("T\n"); |
Rvs94 | 0:97d039743c1c | 34 | break; |
Rvs94 | 0:97d039743c1c | 35 | |
Rvs94 | 0:97d039743c1c | 36 | default: |
Rvs94 | 0:97d039743c1c | 37 | motor2direction = 0; |
Rvs94 | 0:97d039743c1c | 38 | motor2speed = 0; |
Rvs94 | 0:97d039743c1c | 39 | led = 1; |
Rvs94 | 0:97d039743c1c | 40 | } |
Rvs94 | 0:97d039743c1c | 41 | } |
Rvs94 | 0:97d039743c1c | 42 | } |