
Endelig kildekode med rettelser.
Fork of EndeligKildekode by
robot.cpp
- Committer:
- kimnielsen
- Date:
- 2016-12-12
- Revision:
- 8:5ca76759a67e
- Parent:
- 7:a852e63cac3d
- Child:
- 9:f14532fd7a02
File content as of revision 8:5ca76759a67e:
/* ============================================================================ Name : robot.cpp Author : Team 5 Version : 0.1 Date : 13-10-2016 Copyright : Open for all Description : Program to serve the platform for Pro1 2016 ============================================================================ */ #include "odometry.h" #include "mbed.h" #include "hack_motor.h" #include <math.h> void startfunction( ); Ticker T1; // create an object T1 of Ticker int main() { ///////////////////////////////////////////////////////////////////////////// // Driving setup // ///////////////////////////////////////////////////////////////////////////// while(1) { startfunction(); get_to_goal(); robot.stop(); printf("\n\r DistanceBysensor: %.2f \n", Dcenter()); wait_ms(2000); init(); startfunction(); turn(); 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 //to the falling edge init(); // initialise parameters (just for you to remember if you need to) wait_ms(2000); //wait 1 secs here before you go t.start(); // start timer (just demo of how you can use a timer) }