E2016-S1-Team5
/
Team5
Fork of Robotkode by
robot.cpp
- Committer:
- kimnielsen
- Date:
- 2016-12-09
- Revision:
- 7:a852e63cac3d
- Parent:
- 6:c2d4a02115db
File content as of revision 7:a852e63cac3d:
/* ============================================================================ 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) //Remember to include if statement to stop robot if it's time to recharge { read_analog(); startfunction(); get_to_goal(); robot.stop(); printf("\n\r DistanceBysensor: %.2f \n", Dcenter()); wait_ms(2000); read_analog(); startfunction(); get_to_goal(); robot.stop(); printf("\n\r DistanceBysensor: %.2f \n", Dcenter()); wait_ms(2000); read_analog(); startfunction(); get_to_goal(); robot.stop(); printf("\n\r DistanceBysensor: %.2f \n", Dcenter()); wait_ms(2000); read_analog(); startfunction(); get_to_goal(); robot.stop(); printf("\n\r DistanceBysensor: %.2f \n", Dcenter()); wait_ms(2000); } } /* ---------------------------------------------------------------------------- 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) }