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-20
Revision:
9:6ae4359b73df
Parent:
8:fd8a30a6923d
Child:
10:7ef481d28dcd

File content as of revision 9:6ae4359b73df:

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

m3pi thinggy;


int main() {
    
    float speed = 0.1;
    float threshold = 0.1;
    
    thinggy.locate(0,1);
    thinggy.printf("Line Flw");
    
    wait(2.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();
 
        // Line is more than the threshold to the right, slow the left motor
        if (position > threshold) {
            thinggy.right(speed);
            
        }
 
        // Line is more than 50% to the left, slow the right motor
        else if (position < -threshold) {
            thinggy.left_motor(speed);
            
        }
 
        // Line is in the middle
        else {
            thinggy.forward(speed);
        }
    }
}