![](/media/cache/profiles/25a76ba89c58a499eadfd4cb8ecf8af5.jpg.50x50_q85.jpg)
Lab02
Diff: main.cpp
- Revision:
- 1:1a7f5ec34d63
- Parent:
- 0:f5f8ea653b56
--- a/main.cpp Fri Jan 17 02:22:02 2014 +0000 +++ b/main.cpp Fri Jan 17 02:39:11 2014 +0000 @@ -18,13 +18,16 @@ double sign = -1.0; /*******************************************************************************/ int main(){ + pc.printf("%s %s \n\r", "Servo","DC Motor"); while(1){ myservo.calibrate(.0009,90); //Code provideed by CAPT Shorr to calibrate Servo sign = sign * -1.0; //Sign tells servo whether to increment or decrement based on which phase of the cycle it is in while(turn > 0 && turn < 1){ //While the servo is completing one full rotation continue to turn... myservo = turn; turn += .005 * sign; //...based upon wether the servo is in the forward or backwrd phase of its ocilation + pc.printf("%.2f %.2f\r", turn, speed); wait(.0125); + } if(sign > 0){turn = .9999999;} //Same concept as on the comment when variable was initialized else{turn = .000001;} @@ -41,9 +44,9 @@ speed -= .2; // (as indicated by a -1 on the sign) and the motor is decellerating, decrease the speed by 20% DCmotor = speed; } - //pc.printf("%f\n",speed); + - pc.printf("%.2f %.2f %d %d \r",turn,speed,direction,sign); + //pc.printf(" %.2f %d \r",speed); } } \ No newline at end of file