Library for using the xbee-compatible Bluetooth Bee Module on an m3pi.

Dependencies:   SensoryTest

Fork of btbee by Nikolas Goldin

main.cpp

Committer:
mmpeter
Date:
2014-05-21
Revision:
11:45172e28ecb2
Parent:
10:7ef481d28dcd
Child:
12:6b5dd9e5469c

File content as of revision 11:45172e28ecb2:

#include "mbed.h"
#include "m3pi_ng.h"

m3pi thinggy;


int main() {
    
    float speed = 0.5;
    float correction;
    float threshold = 0.5;
    float k = -0.5;
    
    thinggy.locate(0,1);
    thinggy.printf("Line Flw");
    
    wait(1.0);
    
    thinggy.sensor_auto_calibrate();
    while(1) {
        
        
         // -1.0 is far left, 1.0 is far right, 0.0 in the middle
        float position = thinggy.line_position();
        correction = k*(position);
        
        //speed limiting for right motor
        if(speed + correction > 1){
            thinggy.right_motor(1);
        }
        else{
            thinggy.right_motor(speed+correction);
        }
        
        //speed limiting for left motor
        if(speed - correction > 1){
            thinggy.left_motor(1);
        }
        else{
            thinggy.left_motor(speed-correction);
        }
            
        
 
      }
    }