Draaiende motor op commando van knopje (WERKEND)
Dependencies: Encoder MODSERIAL mbed
Fork of P_controller_motor by
main.cpp@12:27abe8ee588c, 2015-09-21 (annotated)
- Committer:
- ThomasBNL
- Date:
- Mon Sep 21 09:31:05 2015 +0000
- Revision:
- 12:27abe8ee588c
- Parent:
- 11:c5befe79aa53
Werkende motor: motor draait beide richtingen op commando van knopje
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ThomasBNL | 0:843492f4fe62 | 1 | #include "mbed.h" |
ThomasBNL | 0:843492f4fe62 | 2 | #include "HIDScope.h" |
ThomasBNL | 3:eee8d5461256 | 3 | #include "encoder.h" |
bscheltinga | 11:c5befe79aa53 | 4 | #include "MODSERIAL.h" |
ThomasBNL | 4:dfdfcb518e60 | 5 | |
ThomasBNL | 12:27abe8ee588c | 6 | //Motor 2 |
bscheltinga | 11:c5befe79aa53 | 7 | DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield) |
bscheltinga | 11:c5befe79aa53 | 8 | PwmOut motor2speed(D5); |
ThomasBNL | 12:27abe8ee588c | 9 | DigitalIn button(PTA4); |
ThomasBNL | 6:34b39eb3dcb6 | 10 | |
ThomasBNL | 0:843492f4fe62 | 11 | int main() |
ThomasBNL | 3:eee8d5461256 | 12 | { |
ThomasBNL | 12:27abe8ee588c | 13 | while(true) { |
ThomasBNL | 12:27abe8ee588c | 14 | if (button.read() < 0.5) { |
ThomasBNL | 12:27abe8ee588c | 15 | motor2direction = 1; |
ThomasBNL | 12:27abe8ee588c | 16 | motor2speed = 0.2f; |
ThomasBNL | 12:27abe8ee588c | 17 | } else { |
ThomasBNL | 12:27abe8ee588c | 18 | motor2direction = 0; |
ThomasBNL | 12:27abe8ee588c | 19 | motor2speed = 0.2f; |
ThomasBNL | 12:27abe8ee588c | 20 | } |
ThomasBNL | 12:27abe8ee588c | 21 | } |
ThomasBNL | 3:eee8d5461256 | 22 | } |
ThomasBNL | 12:27abe8ee588c | 23 | |
ThomasBNL | 12:27abe8ee588c | 24 | // Geen functie hieronder nog |
ThomasBNL | 12:27abe8ee588c | 25 | Encoder encoder1(D13,D12); |