speed increment for loop
Dependencies: Encoder HIDScope MODSERIAL mbed
main.cpp@1:e0c4625bbbab, 2015-09-20 (annotated)
- Committer:
- Vigilance88
- Date:
- Sun Sep 20 16:31:03 2015 +0000
- Revision:
- 1:e0c4625bbbab
- Parent:
- 0:4bfe85fb30ab
- Child:
- 2:c8a030f3b4e7
simpeler;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Vigilance88 | 0:4bfe85fb30ab | 1 | #include "mbed.h" |
Vigilance88 | 0:4bfe85fb30ab | 2 | #include "encoder.h" |
Vigilance88 | 0:4bfe85fb30ab | 3 | |
Vigilance88 | 0:4bfe85fb30ab | 4 | |
Vigilance88 | 1:e0c4625bbbab | 5 | Encoder encoder1(D13,D12); |
Vigilance88 | 1:e0c4625bbbab | 6 | DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield) |
Vigilance88 | 1:e0c4625bbbab | 7 | PwmOut motor2speed(D5); |
Vigilance88 | 0:4bfe85fb30ab | 8 | |
Vigilance88 | 0:4bfe85fb30ab | 9 | |
Vigilance88 | 0:4bfe85fb30ab | 10 | int main() |
Vigilance88 | 0:4bfe85fb30ab | 11 | { |
Vigilance88 | 1:e0c4625bbbab | 12 | int position = encoder1.getPosition(); |
Vigilance88 | 0:4bfe85fb30ab | 13 | Serial pc(USBTX,USBRX); |
Vigilance88 | 0:4bfe85fb30ab | 14 | pc.baud(9600); |
Vigilance88 | 0:4bfe85fb30ab | 15 | motor2speed=0.0f; |
Vigilance88 | 0:4bfe85fb30ab | 16 | motor2direction=1; |
Vigilance88 | 1:e0c4625bbbab | 17 | |
Vigilance88 | 0:4bfe85fb30ab | 18 | |
Vigilance88 | 0:4bfe85fb30ab | 19 | if(stop_knop.read() == 0) { |
Vigilance88 | 0:4bfe85fb30ab | 20 | motor2speed=0.0f; |
Vigilance88 | 0:4bfe85fb30ab | 21 | } |
Vigilance88 | 0:4bfe85fb30ab | 22 | while (true) { |
Vigilance88 | 0:4bfe85fb30ab | 23 | |
Vigilance88 | 1:e0c4625bbbab | 24 | pc.printf("pos: %d, speed %f \r\n",encoder1.getPosition(), encoder1.getSpeed()); |
Vigilance88 | 0:4bfe85fb30ab | 25 | } |
Vigilance88 | 0:4bfe85fb30ab | 26 | } |