Lab 11 – Performance Test 4

Description of Code: This was the code that was used during the final test. This code differs from the code in the other two Performance Test since this one added in a servo as a brake. Everything almost remained the same in comparison to the previous one except when the AEV was stopping at the gate along with the end where the AEV arrives with R2D2. The servo acted as a brake near the gates in order to have consistency when stopping. It also helped at the end so it wouldn’t crash in the foam block with too much force.


Servo myservo;

myservo.attach(9);

myservo.write(0);

 

//reverse all motors

reverse(4);

 

//motors run at 20% for 13.5 ft which 332.2 marks

 

motorSpeed(4,22);

goToAbsolutePosition(150);

 

motorSpeed(4,18);

goToAbsolutePosition(270);

 

// reverse(4);

// motorSpeed(4,25);

// goFor(1.5);

 

//brake all motors

brake(4);

goToAbsolutePosition(380);

 

myservo.write(37);

goFor(2);

myservo.write(0);

 

goFor(6);

//everything above is to get to the gate

 

motorSpeed(4,25);

goFor(2);

 

motorSpeed(4,22);

goToAbsolutePosition(630);

 

//R2D2 capture

 

brake(4);

goFor(10);

 

reverse(4);

 

motorSpeed(4,40);

goToAbsolutePosition(600);

 

motorSpeed(4,20);

goToAbsolutePosition(540);

 

brake(4);

goToAbsolutePosition(443);

 

myservo.write(39);

goFor(2);

myservo.write(0);

 

//  reverse(4);

//  motorSpeed(4,20);

//  goFor(2);

//  reverse(4);

 

brake(4);

goFor(6);

 

//at the gate

 

//return to start

 

motorSpeed(4, 38);

goToAbsolutePosition(160);

 

brake(4);

 

goToAbsolutePosition(10);

myservo.write(39);

goFor(2);

myservo.write(0);