Code for AHRC Triathalon

Dependencies:   m3pi mbed

main.cpp

Committer:
mpanetta
Date:
2016-03-09
Revision:
0:e6d2aeb6f9cd

File content as of revision 0:e6d2aeb6f9cd:

#include "mbed.h"
#include "m3pi.h"

m3pi m3pi;

// Minimum and maximum motor speeds
#define MAX 0.5
#define MIN 0

// PID terms


int main() {

    m3pi.locate(0,1);
    m3pi.printf("DR Floor");

    wait(2.0);

   

    float right;
    float left;


    float speed = MAX;
    
 
     
     
        // Compute new speeds   
        right = speed;
        left  = speed;
        
       
       // set speed 
        m3pi.left_motor(left);
        m3pi.right_motor(right);
        wait(2.3); // The value that determines the distance travelled on the first line segment
        m3pi.left_motor(0);
        m3pi.right_motor(0);
        wait(0.5);
        m3pi.left_motor(.5);
        m3pi.right_motor(0);
        wait(0.35); // The value that sets the angle of the turn based on time
        m3pi.left_motor(0);
        m3pi.right_motor(0);
        wait(1.0);

   
        m3pi.left_motor(left);
        m3pi.right_motor(right);
        wait(2.3); // The value that determines the distance travelled on the second line segment
        m3pi.left_motor(0);
        m3pi.right_motor(0);
        wait(0.5);
        m3pi.left_motor(.5);
        m3pi.right_motor(0);
        wait(0.35); // The value that sets the angle of the turn based on time
        m3pi.left_motor(0);
        m3pi.right_motor(0);
        wait(1.0);
        
        m3pi.left_motor(left);
        m3pi.right_motor(right);
        wait(2.25); // The value that determines the distance travelled on the third line segment
        m3pi.left_motor(0);
        m3pi.right_motor(0);
       
}