Alle functies van de motoren werken
Dependencies: MODSERIAL QEI mbed
Fork of worknotjet by
Diff: main.cpp
- Revision:
- 5:353ed56417a2
- Parent:
- 4:7b8bf798bb72
- Child:
- 6:4e4df2f6157e
--- a/main.cpp Fri Oct 14 10:34:17 2016 +0000 +++ b/main.cpp Mon Oct 17 12:41:39 2016 +0000 @@ -21,52 +21,48 @@ MODSERIAL pc(USBTX, USBRX); bool draairechts; bool draailinks; - +bool turnthedamthing = 0; +float waiter = 0.1; void GetDirections() { - if ((rechts == 1) && (links == 1)) - {} - else if ((rechts == 1) && (draailinks == 0)) { + pc.baud(115200); + if ((rechts == 0) && (links == 0) && (turnthedamthing == 0)) { + draailinks = 0; + draairechts = 0; + turnthedamthing = 1; + pc.printf("begin de actie \n \r "); + wait(waiter); + + } else if ((rechts == 0) && (links == 0) && (turnthedamthing == 1)) { + draailinks = 0; + draairechts = 0; + turnthedamthing = 0; + pc.printf("breek de actie af \n \r "); + wait(waiter); + } else if ((rechts == 1) && (links == 1)) { + + } else if ((rechts == 1) && (draailinks == 0)) { + /* if the right button is pressed and the motor isn't rotating to the left, + then start rotating to the right etc*/ draairechts = !draairechts; + pc.printf("draai naar rechts \n \r "); + wait(waiter); } else if ((rechts == 1) && (draailinks == 1)) { draailinks = 0; draairechts = !draairechts; - } else if (links == 1) { + pc.printf("draai naar rechts na links \n \r "); + wait(waiter); + } else if ((links == 1) && (draairechts == 0)) { draailinks = !draailinks; + pc.printf("draai naar links \n \r "); + wait(waiter); } else if ((links == 1) && (draairechts == 1)) { draairechts = 0; draailinks = !draailinks; + pc.printf("draai naar links na rechts \n \r "); + wait(waiter); } - wait(0.1); - /*if ((rechts == 0) && (links == 0)) { - draairechts = false; - draailinks = false; - } else if ((rechts == 1) && (draairechts ==false)) { //Als je rechts aanspant en hij draait nog niet naar rechts - draairechts = true; - draailinks = false; - } else if ((rechts == 1) && (draairechts == true)) { //Als je rechts aanspant en hij draait al naar rechts - draairechts = false; - draailinks = false; - } else if ((links == 1) && (draailinks == false)) { //Als je links aanspant en hij draait nog niet naar links - draailinks = true; - draairechts = false; - } else if ((links == 1) && (draailinks == true)) { // Als je links aanspant en hij draait al naar links - draailinks = false; - draairechts = false; - } - - else if ((links == 1 && draairechts == true)) { // Als je links aanspant en hij draait nog naar rechts - draailinks = true; - draairechts = false; - } else if ((rechts == 1 && draailinks == true)) { // Als je rechts aanspant en hij draait nog naar links - draairechts = true; - draailinks = false; - - } else { - draairechts = false; - draailinks = false; - } - */ + wait(2*waiter); } int main() { @@ -152,7 +148,7 @@ } else if ((draailinks == false) && (draairechts == false)) { M1_Speed = 0; } - + /*