Samenwerking Groep 12
Dependencies: Encoder MODSERIAL HIDScope mbed
Foo
main.cpp@6:e743bf8b9a59, 2015-09-21 (annotated)
- Committer:
- ThomasBNL
- Date:
- Mon Sep 21 11:31:29 2015 +0000
- Revision:
- 6:e743bf8b9a59
- Parent:
- 5:14f6189d86a2
- Child:
- 7:b2b1d1c36861
ENCODER handmatig werkend positie weergave
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ThomasBNL | 6:e743bf8b9a59 | 1 | //#include "mbed.h" |
ThomasBNL | 6:e743bf8b9a59 | 2 | //#include "HIDScope.h" |
ThomasBNL | 6:e743bf8b9a59 | 3 | //#include "encoder.h" |
ThomasBNL | 6:e743bf8b9a59 | 4 | //#include "MODSERIAL.h" |
ThomasBNL | 6:e743bf8b9a59 | 5 | // |
ThomasBNL | 6:e743bf8b9a59 | 6 | ////Motor 2 |
ThomasBNL | 6:e743bf8b9a59 | 7 | //DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield) |
ThomasBNL | 6:e743bf8b9a59 | 8 | //PwmOut motor2speed(D5); |
ThomasBNL | 6:e743bf8b9a59 | 9 | //DigitalIn button(PTA4); |
ThomasBNL | 6:e743bf8b9a59 | 10 | //Encoder motor2(D13,D12); |
ThomasBNL | 6:e743bf8b9a59 | 11 | //MODSERIAL pc(USBTX,USBRX); |
ThomasBNL | 6:e743bf8b9a59 | 12 | // |
ThomasBNL | 6:e743bf8b9a59 | 13 | // |
ThomasBNL | 6:e743bf8b9a59 | 14 | //int main() |
ThomasBNL | 6:e743bf8b9a59 | 15 | //{ |
ThomasBNL | 6:e743bf8b9a59 | 16 | // pc.baud(9600); |
ThomasBNL | 6:e743bf8b9a59 | 17 | // while(true) { |
ThomasBNL | 6:e743bf8b9a59 | 18 | // if (button.read() < 0.5) { //if button pressed |
ThomasBNL | 6:e743bf8b9a59 | 19 | // motor2direction = 1; |
ThomasBNL | 6:e743bf8b9a59 | 20 | // motor2speed = 0.5f; |
ThomasBNL | 6:e743bf8b9a59 | 21 | // pc.printf("positie = %d \n", motor2.getPosition()); |
ThomasBNL | 6:e743bf8b9a59 | 22 | // } else { // If button is not pressed |
ThomasBNL | 6:e743bf8b9a59 | 23 | // motor2direction = 0; |
ThomasBNL | 6:e743bf8b9a59 | 24 | // motor2speed = 0; |
ThomasBNL | 6:e743bf8b9a59 | 25 | // motor2.setPosition(0); |
ThomasBNL | 6:e743bf8b9a59 | 26 | // pc.printf("positie = %d \n", motor2.getPosition()); |
ThomasBNL | 6:e743bf8b9a59 | 27 | // } |
ThomasBNL | 6:e743bf8b9a59 | 28 | // } |
ThomasBNL | 6:e743bf8b9a59 | 29 | //} |
ThomasBNL | 6:e743bf8b9a59 | 30 | |
ThomasBNL | 6:e743bf8b9a59 | 31 | |
ThomasBNL | 0:86df750eeab8 | 32 | #include "mbed.h" |
ThomasBNL | 6:e743bf8b9a59 | 33 | #include "MODSERIAL.h" |
ThomasBNL | 0:86df750eeab8 | 34 | #include "HIDScope.h" |
ThomasBNL | 0:86df750eeab8 | 35 | #include "encoder.h" |
ThomasBNL | 0:86df750eeab8 | 36 | |
ThomasBNL | 6:e743bf8b9a59 | 37 | Encoder foo(D13,D12); |
ThomasBNL | 6:e743bf8b9a59 | 38 | MODSERIAL pc(USBTX,USBRX); |
ThomasBNL | 0:86df750eeab8 | 39 | |
ThomasBNL | 0:86df750eeab8 | 40 | int main() |
ThomasBNL | 0:86df750eeab8 | 41 | { |
ThomasBNL | 6:e743bf8b9a59 | 42 | foo.setPosition(0); |
ThomasBNL | 6:e743bf8b9a59 | 43 | pc.baud(9600); |
ThomasBNL | 6:e743bf8b9a59 | 44 | while (true) { |
ThomasBNL | 6:e743bf8b9a59 | 45 | pc.printf("position: %d, speed: %.20f\r\n", encoder1.getPosition(), encoder1.getSpeed()); |
ThomasBNL | 0:86df750eeab8 | 46 | } |
ThomasBNL | 0:86df750eeab8 | 47 | } |