Software for mapping with the Lidar lite v2, stepper motor, and stepper motor driver

Dependencies:   DRV88255 LidarLitev2 MODSERIAL mbed

Revision:
0:8327d88550ab
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Dec 11 15:51:05 2015 +0000
@@ -0,0 +1,46 @@
+#include "LidarLitev2.h"
+#include "DRV8825.h"
+#include "MODSERIAL.h"
+#include "math.h"
+
+#define PI 3.14159265359
+
+Serial pc(USBTX, USBRX);
+
+DRV8825 stpr_mtr(p21, p22, p23, p24, p25, p26);
+DigitalIn pinMode(p19); 
+
+LidarLitev2 Lidar(p28, p27);
+
+
+int main()
+{   
+    stpr_mtr.direction = 1;
+    pc.baud(9600);
+    Lidar.configure();
+    //Lidar.beginContinuous();
+    float degree = 0, x, y;
+    int distance;
+    char e;
+    while(1){
+         if(pc.readable()) {
+             e = pc.getc();
+        }
+        while (e == 'e'){
+         //if(!pinMode) {  //Check if the lidar is pulling low
+            distance = Lidar.distance();
+            x = distance*cos(degree*(PI/180));
+            y =  distance*sin(degree*(PI/180));
+            stpr_mtr.settings(1, 0, 400);
+            degree += .45;
+            if(degree >= 360) degree = 0;
+            //pc.printf("%4d,%4.0f\n", distance, degree);
+            pc.printf("%4.0f,%4.0f\n", x, y);
+          //}
+          if(pc.readable()) {
+             e = pc.getc();
+            }
+          if (e == 's') break;
+        }
+    }
+}
\ No newline at end of file