Samenwerking Groep 12
Dependencies: Encoder MODSERIAL HIDScope mbed
Foo
main.cpp@3:61c024f896ad, 2015-09-21 (annotated)
- Committer:
- bscheltinga
- Date:
- Mon Sep 21 10:43:37 2015 +0000
- Revision:
- 3:61c024f896ad
- Parent:
- 2:3de3c5eb400f
- Child:
- 4:a92d354265b2
Added position read and print with Getposition
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ThomasBNL | 0:86df750eeab8 | 1 | #include "mbed.h" |
ThomasBNL | 0:86df750eeab8 | 2 | #include "HIDScope.h" |
ThomasBNL | 0:86df750eeab8 | 3 | #include "encoder.h" |
ThomasBNL | 0:86df750eeab8 | 4 | #include "MODSERIAL.h" |
ThomasBNL | 0:86df750eeab8 | 5 | |
ThomasBNL | 0:86df750eeab8 | 6 | //Motor 2 |
ThomasBNL | 0:86df750eeab8 | 7 | DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield) |
ThomasBNL | 0:86df750eeab8 | 8 | PwmOut motor2speed(D5); |
ThomasBNL | 0:86df750eeab8 | 9 | DigitalIn button(PTA4); |
ThomasBNL | 0:86df750eeab8 | 10 | |
ThomasBNL | 0:86df750eeab8 | 11 | int main() |
ThomasBNL | 0:86df750eeab8 | 12 | { |
ThomasBNL | 0:86df750eeab8 | 13 | while(true) { |
bscheltinga | 3:61c024f896ad | 14 | if (button.read() == 0) { //if button pressed |
ThomasBNL | 0:86df750eeab8 | 15 | motor2direction = 1; |
bscheltinga | 2:3de3c5eb400f | 16 | motor2speed = 0.3f; |
bscheltinga | 3:61c024f896ad | 17 | } else { // If button is not pressed |
ThomasBNL | 0:86df750eeab8 | 18 | motor2direction = 0; |
ThomasBNL | 0:86df750eeab8 | 19 | motor2speed = 0.3f; |
ThomasBNL | 0:86df750eeab8 | 20 | } |
bscheltinga | 3:61c024f896ad | 21 | double position = getPosition(); |
bscheltinga | 3:61c024f896ad | 22 | printf("positie = %d", position); |
ThomasBNL | 0:86df750eeab8 | 23 | } |
ThomasBNL | 0:86df750eeab8 | 24 | } |
ThomasBNL | 0:86df750eeab8 | 25 | |
ThomasBNL | 0:86df750eeab8 | 26 | // Geen functie hieronder nog |
bscheltinga | 3:61c024f896ad | 27 | // Encoder encoder1(D13,D12); |