Vincent Ceyssens
/
4180_Final_turning
Turning function
Diff: main.cpp
- Revision:
- 0:84070c2a9436
diff -r 000000000000 -r 84070c2a9436 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 01 01:03:22 2017 +0000 @@ -0,0 +1,83 @@ +#include "mbed.h" +#include "rtos.h" + +Serial pc(USBTX, USBRX); +DigitalOut start(p30,1); +DigitalOut right(p29,1); +DigitalOut left(p28,1); +DigitalOut up(p27,1); +DigitalOut down(p26,1); +DigitalOut on_switch(p25,0); +DigitalOut myled(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); +DigitalIn encoder(p20); + + +void starting_commands(){ // toggles the button to start the cop car + start = 0; + wait(0.1); + start = 1; + wait(0.1); + } + + +void start_func() // sequence that gets the cop car into no noise run mode +{ + on_switch =1; + starting_commands(); + starting_commands(); + starting_commands(); + starting_commands(); + starting_commands(); +} + +int first_time = 0; +int last_time = 0; + +void drive(){ + + + right = 0; + wait(0.1); + up = 0; + wait(0.4); + up = right = 1; + wait(0.2); + +} + +void reverse(){ + + left = 0; + wait(0.1); + down = 0; + wait(0.4); + down= left=1; + wait(0.2); +} + +int main() { + start_func(); + drive(); + reverse(); + drive(); + reverse(); + drive(); + reverse(); + drive(); + reverse(); + drive(); + reverse(); + drive(); + reverse(); + drive(); + reverse(); + drive(); + reverse(); + drive(); + reverse(); + + +}