Final

Dependencies:   mbed

Fork of MiniProject5_LightTracker by Austin Sloop

Files at this revision

API Documentation at this revision

Comitter:
asloop18
Date:
Tue Jan 12 01:41:19 2016 +0000
Parent:
13:871d01d0d250
Commit message:
Mission Accomplished; ; Working Version

Changed in this revision

SegDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
ServoControl.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 871d01d0d250 -r 69cad6d9a2e5 SegDisplay.cpp
--- a/SegDisplay.cpp	Tue Jan 12 01:12:23 2016 +0000
+++ b/SegDisplay.cpp	Tue Jan 12 01:41:19 2016 +0000
@@ -34,13 +34,16 @@
     for(int i=0;i<25;i++)
     {
         if(x<0){Negative=1;}
+        else{Negative=0;}
+        wait(0.001);
+        Negative=0;
         Display1 =1;
-        Display = SegConvert(x/10);
+        Display = SegConvert(abs(x)/10);
         wait(.001);
         Display1=0;
-        
+        wait(0.0005);
         Display10 = 1;
-        Display = SegConvert(x%10);
+        Display = SegConvert(abs(x)%10);
         wait(.001);
         Display10=0;  
     }     
diff -r 871d01d0d250 -r 69cad6d9a2e5 ServoControl.cpp
--- a/ServoControl.cpp	Tue Jan 12 01:12:23 2016 +0000
+++ b/ServoControl.cpp	Tue Jan 12 01:41:19 2016 +0000
@@ -8,9 +8,9 @@
     ServoSignal.period(0.020);
 }
 
-int ServoControl(int angle){
-    if(angle<-90){angle=-90;}
-    if(angle>90){angle=90;}
+int ServoControl(signed int angle){
+    if(angle<-90){angle=-89;}
+    if(angle>90){angle=89;}
     ServoSignal.pulsewidth_us(1500+10*angle); 
     return angle;
 }
diff -r 871d01d0d250 -r 69cad6d9a2e5 main.cpp
--- a/main.cpp	Tue Jan 12 01:12:23 2016 +0000
+++ b/main.cpp	Tue Jan 12 01:41:19 2016 +0000
@@ -22,9 +22,9 @@
     val1 = sensor1;
     val2 = sensor2;
     pc.printf("%.2f \t %.2f\n\r", val1, val2);
-    if((val1+0.01)<val2){angle=angle+5;}
-    if(val1>(val2+0.01)){angle=angle-5;}
-    ServoControl(angle);
+    if((val1+0.03)>val2){angle=angle+1;}
+    if(val1<(val2+0.03)){angle=angle-1;}
+    angle=ServoControl(angle);
     SegDisplay(angle);
 }
 }