
Endelig kildekode med rettelser.
Fork of EndeligKildekode by
Diff: robot.cpp
- Revision:
- 9:f14532fd7a02
- Parent:
- 8:5ca76759a67e
--- a/robot.cpp Mon Dec 12 13:35:34 2016 +0000 +++ b/robot.cpp Thu Dec 15 13:50:26 2016 +0000 @@ -18,32 +18,40 @@ int main() { -///////////////////////////////////////////////////////////////////////////// -// Driving setup // -///////////////////////////////////////////////////////////////////////////// - - while(1) + startfunction(); + distance = 2000; + get_to_goal();; + robot.stop(); + distance = 4500; + wait_ms(1000); + + init(); + while(tickR <= 16) { + robot.FW(0.5, 0); + wait_ms(10); + } + robot.stop(); + + while(1) + { + init(); startfunction(); get_to_goal(); - robot.stop(); - printf("\n\r DistanceBysensor: %.2f \n", Dcenter()); - wait_ms(2000); + robot.stop(); + wait_ms(1000); - init(); - startfunction(); - turn(); - robot.stop(); - } + init(); + while(tickR <= 16) + { + robot.FW(0.5, 0); + wait_ms(10); + } + robot.stop(); } -/* ----------------------------------------------------------------------------- - END OF MAIN FUNCTION -----------------------------------------------------------------------------*/ +} void startfunction() { - T1.attach(&read_analog, 1.0); // attach the address of the read_analog - //function to read analog in every second tacho_left.rise(&tickLeft); // attach the address of the count function //to the falling edge tacho_right.rise(&tickRight); // attach the address of the count function