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:
15:cc5b8a858c6e
Parent:
14:7ddbd9f475ad
Child:
16:2b437630e29e

File content as of revision 15:cc5b8a858c6e:

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

m3pi thinggy;


int main() {
    
    float speed = 0.5;
    float correction;
    float k = -0.7;
    
    
    thinggy.locate(0,1);
    thinggy.printf("HellzYa");
    
    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(0.6);
        }
        else if(speed + correction <= 0){
            thinggy.right_motor(0.1);
        }
        else{
            thinggy.right_motor(speed+correction);
        }
        
        //speed limiting for left motor
        if(speed - correction > 1){
            thinggy.left_motor(0.6);
        }
        else if(speed - correction <= 0){
            thinggy.left_motor(0.1);
        }
        else{
            thinggy.left_motor(speed-correction);
        }
            
        

        
      }
    }