Library for using the xbee-compatible Bluetooth Bee Module on an m3pi.
Dependencies: SensoryTest
Fork of btbee by
main.cpp
- Committer:
- mmpeter
- Date:
- 2014-05-20
- Revision:
- 10:7ef481d28dcd
- Parent:
- 9:6ae4359b73df
- Child:
- 11:45172e28ecb2
File content as of revision 10:7ef481d28dcd:
#include "mbed.h" #include "m3pi_ng.h" m3pi thinggy; int main() { float speed = 0.1; float correction = 0.5; float threshold = 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(); // Too far to the right--slow left motor if (position > threshold) { thinggy.right_motor(speed); thinggy.left_motor(speed-correction); } // Too far to the left--slow right motor else if (position < -threshold) { thinggy.left_motor(speed); thinggy.right_motor(speed-correction); } // Default: Centered else { thinggy.forward(speed); } } }