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