First Code
void myCode()
{
//Sets the motors to initially reverse
reverse(4);
//Sets the motor speed of all motors to 25
motorSpeed(4,25);
// Goes to the gate
goToAbsolutePosition(450);
} //end of myCode()
Second Code
AEV_Controller:
…
// AEV Servo
Servo aevServo;
// Additional Servo added by team, in order to use two servos
Servo aevServo1;
…
// Servo Pin—————————————————————–
aevServo.attach(9);
aevServo1.attach(10); // Attaching the second servo
rotateServo(0,0); // Initialize servo 0 to 0 degrees
rotateServo(1,0); // Initialize servo 1 (the added servo) to 0 degrees
…
_07_rotateServo:
void rotateServo(byte servo, float angle)
{
//————————————————————–
// rotateServo(angle);
//
// Rotates servo
//
// Input: servo : which servo to change; Added by team
// angle : servo angle (0 – 180 degrees).
//
//
// Output: none
//————————————————————–
// Check motor input. If incorrect, display error in serial port for user.
if (angle < 0.00) angle = 0.00;
if (angle > 180.00) angle = 180.00;
// Map out the angle provided by the user
int ms = map(angle, 0.00, 180.00, 544, 2400);
// Rotate servo; If statement added by team
if (servo == 1) {
aevServo2.writeMicroseconds(ms);
} else {
aevServo.writeMicroseconds(ms);
}
}
myCode:
void myCode()
{
//————————————————————————–
// myCode();
//
// This is the tab where the programming of your vehicle is done.
// Tab_00_AEV_key_words contains a compiled list of functions/subroutines used for vehicle
// operation.
//
//————————————————————————–
// Releases the braking servo and lets the AEV travel 400 marks forward
rotateServo(0,90);
goToRelativePosition(400);
// Engages the braking servo, stopping the AEV before the gate
rotateServo(0,0);
// Waits at the gate for 7 seconds
goFor(7.0);
// Releases the braking servo and lets the AEV travel 400 marks, to the pickup location
rotateServo(0,90);
goToRelativePosition(400);
// Takes the spring torsion off of the wheel by rotating a servo that moves the driving gear; this allows the AEV to gently coast for 3 seconds into the caboose
rotateServo(1,45);
goFor(3.0);
// Re-engages spring torsion but in the opposite direction, allowing the AEV to begin its travel back to the gate, 400 marks away
rotateServo(1,90);
goFor(-400);
// Engages the braking servo, stopping the AEV before the gate
rotateServo(0,0);
// Waits at the gate for 7 seconds
goFor(7.0);
// Releases the braking servo and lets the AEV travel 400 marks, to the starting location
rotateServo(0,90);
goToRelativePosition(-400);
// Engages the braking servo, stopping the AEV at the starting position
rotateServo(0,0);
} // end of void myCode()
Final Code
void myCode()
{
reverse(4);
// Drives the AEV to the first stop at the gate
motorSpeed(4,35);
goToRelativePosition(453);
// Stops the AEV at the gate
motorSpeed(4,0);
// Engages the braking servo and brakes for 2 seconds
rotateServo(30);
goFor(2.0);
// Disengages the braking servo
rotateServo(0);
// Waits the additional 5.5 seconds at the gate
goFor(6.5);
// Drives the AEV to the caboose
motorSpeed(4,35);
goToRelativePosition(330);
// Stops the AEV at the caboose
motorSpeed(4,0);
// Coasts for 1.5 seconds, into the caboose
goFor(3.0);
// Engages the braking servo and brakes for 4 seconds
rotateServo(30);
goFor(2.0);
// Disengages the braking servo
rotateServo(0);
// Reverses the motor direction
reverse(4);
// Starts the propellers back up and drives the AEV with the caboose back to the gate
motorSpeed(4,44);
goToRelativePosition(-445);
// Stops the AEV at the gate
motorSpeed(4,0);
// Engages the braking servo and brakes for 2 seconds
rotateServo(30);
goFor(2.0);
// Disengages the braking servo
rotateServo(0);
// Waits the additional 5 seconds at the gate
goFor(6.5);
// Drives the AEV and the caboose back to the starting position
motorSpeed(4,44);
goToRelativePosition(-487);
// Stops the AEV and caboose at the starting position
motorSpeed(4,0);
// Engages the braking servo and brakes for 2 seconds
rotateServo(30);
goFor(2.0);
// Disengages the braking servo
rotateServo(0);
} // end of void myCode()
Recent Comments