EE149
/
FinalProject
Final Project files for mBed development.
Diff: main.c
- Revision:
- 37:1d51cf101b03
- Parent:
- 35:a1c14c6d9282
- Child:
- 39:cc8691700d2a
--- a/main.c Wed Dec 10 19:15:52 2014 +0000 +++ b/main.c Fri Dec 12 20:53:45 2014 +0000 @@ -93,9 +93,9 @@ oled_1 = 1; while(1); } - right(180); + right(183); timerWait(.2); - int wiggle_count = 0; + /*int wiggle_count = 0; for( ; fabs(pos = pi.line_position()) > CLOSE_ENOUGH && wiggle_count < WIGGLE_MAX; wiggle_count++) { @@ -103,10 +103,11 @@ pi.cls(); pi.locate(0,0); pi.printf("O: %f", pos); - } - pi.stop(); + }*/ + pi.stop(); timerWait(0.2); backward(400); + //while(1); // --------------------------------------------------------- // DONE calibrating. Begin reading in coordinate @@ -158,6 +159,7 @@ pi.cls(); pi.locate(0,0); pi.printf("%s", instbuf+1); + oled_3 = 0; while(1); } @@ -211,6 +213,7 @@ pi.cls(); pi.locate(0,0); pi.printf("a:%f", delta_a); + oled_3 = 0; left(delta_a); /* Put pen into position. */ @@ -290,9 +293,9 @@ pi.right_motor(DRIVE_SPEED); ms = t.read_ms(); while(ms < amt) { - if (ms-last_ms > 1000) { + if (ms-last_ms > 500) { t.stop(); - right(3); + right(1.5); last_ms = ms; t.start(); pi.left_motor(DRIVE_SPEED+.002); @@ -314,15 +317,16 @@ void right(float deg) { + deg += 2; if(deg < 0) { return left(-1*deg); } - deg = deg+1.5; + deg = deg; Timer t; - float amt = ((float)(deg/360)*TIME_FACT); + float amt = ((((float)deg)/360)*TIME_FACT*1000); t.start(); pi.right(TURN_SPEED); - while(t.read_ms() < amt); + while(t.read_us() < amt); pi.stop(); } @@ -338,10 +342,10 @@ if(deg < 0) { return right(-1*deg); } - deg = deg + 1.5; + float amt = (((float)deg)/360)*TIME_FACT*1000; Timer t; pi.left(TURN_SPEED); t.start(); - while(t.read_ms() < ((float)(deg/360)*TIME_FACT)); + while(t.read_us() < amt); pi.stop(); } \ No newline at end of file