Robot Bachelor
/
FinalMotorControl
Engine control program with 3 engines
Fork of MotorControl by
Diff: main.cpp
- Revision:
- 3:15be78948724
- Parent:
- 2:25bcc26f7a5b
- Child:
- 4:4d655fdae399
diff -r 25bcc26f7a5b -r 15be78948724 main.cpp --- a/main.cpp Thu Apr 07 11:05:26 2016 +0000 +++ b/main.cpp Fri Apr 08 13:27:08 2016 +0000 @@ -9,10 +9,8 @@ DigitalOut IN3(D5); DigitalOut IN4(D6); -Mutex stdio_mutex; static int fart = 1000; -static char global_direction; -static int global_counter; +static char m_cmd = 'x'; void step4Right() @@ -70,10 +68,11 @@ { while(true) { - //scanf(" %c", &global_direction); - //global_direction=getchar(); + if(pc.readable()) - { global_direction=pc.getc(); } + { m_cmd=pc.getc(); + + } Thread::wait(10); } @@ -83,26 +82,46 @@ { //Thread 1 has constant feed from usb Thread t1(input); + static char global_direction; + printf("Started"); + while (true) { - step4Left(); - - /* - if (global_direction == '0') + + + if (m_cmd == '0') + { + global_direction = '0'; + step4Left(); + //printf("%c \n" + global_direction); + } + else if (m_cmd == '1') + { + global_direction = '1'; + step4Right(); + //printf("RIGHT \n"); + } + if (m_cmd == 'a') + { + fart = 1000; + + } + else if (m_cmd == 'b') + { + fart = 5000; + } + if (global_direction =='0') { step4Left(); - printf("%c \n" + global_direction); - } */ - /*else if (global_direction == '1') + } + else if (global_direction == '1') { step4Right(); - //printf("RIGHT \n"); - } */ - /* else + } + else { - //Do nothing - - }*/ + global_direction = 'x'; + } } -} //END Main \ No newline at end of file +} //END Main