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