ROCO 104
/
ROCO104_base_Template
Revision 7:a96163893291, committed 2020-05-07
- Comitter:
- james_plym
- Date:
- Thu May 07 16:29:28 2020 +0000
- Parent:
- 6:eac1e6a55274
- Commit message:
- finish product in the basis of time not sensors
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r eac1e6a55274 -r a96163893291 main.cpp --- a/main.cpp Fri Apr 03 15:02:43 2020 +0000 +++ b/main.cpp Thu May 07 16:29:28 2020 +0000 @@ -40,6 +40,38 @@ //Variable 'duty' for programmer to use to vary speed as required set here to #define compiler constant see above float duty=DUTY; // + +void fwdBack(){ + int fBOn = 1; + while(fBOn == 1){ + Wheel.Speed(0.8,0.8); + if (microswitch1 == 1){ + wait(0.2); + Wheel.Speed(-0.8,-0.8); + fBOn = 0; + } + } + } + +void turn(){ + int tOn = 1; + while (tOn == 1){ + + if (microswitch2 == 1){ + wait(0.2); + Wheel.Speed(0.5,0.5); + wait(0.5); + Wheel.Speed(0.0,0.8); + wait(1); + Wheel.Speed(0.8,0.8); + wait(2); + Wheel.Speed(0.8,0.0); + wait(0.5); + tOn = 0; + } + } + } + int main () { pc.baud(9600); //BAUD Rate to 9600 @@ -71,8 +103,22 @@ // YOUR LINES OF CODE for your stratagy go between HERE! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Wheel.Period_in_ms(2);//Set frequency of the PWMs 500Hz - - while (true) { + int on = 1; + + while(on == 1){ + fwdBack(); + turn(); + } + + + + + + + + + + /* while (true) { while(microswitch1 == 0); { @@ -97,15 +143,16 @@ //turn left Wheel.Speed(0.0,0.8); wait(0.5); + } - - +*/ +} // and HERE! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -} // go back to start of while loop +// go back to start of while loop //end of int main()