AEV Project Codes

Arduino Code Functions and Descriptions

Preliminary R&D Lab 1 Code:

//Motor one will accelerate from 0% power to 15% power in 2.5 seconds and then run for 1 second and brake the motors

celerate(1,0,15,2.5);

goFor(1);

brake(1);

 

//Motor two will accelerate from 0% power to 27% power in 4 seconds, then continue running for 2.5 seconds. Then the motors will decelerate from 27% to 15% in one second

celerate(2,0,27,4);

goFor(2.7);

celerate(2,27,15,1);

brake(2);

 

//The second motor will reverse and accelerate from 0% to 31% in 2 second then quickly jump to 35% power and run there for 1 second. The motor will then brake and the first motor will reverse.

reverse(2);

celerate(2,0,31,2);

motorspeed(2,35);

goFor(1);

brake(2);

goFor(3);

brake(4);

reverse(1);

 

// The first motor will accelerate from 0% to 19% in two seconds. The second motor will be set to constant 35%, this will last for two seconds. Then motor two will drop down to 19% and run for 2 seconds. Lastly motor two will slow to a stop in 3 seconds and then motor one will be stopped.

celerate(1,0,19,2);

motorSpeed(2,35);

goFor(2);

motorSpeed(2,19);

goFor(2);

celerate(4,19,0,3);

brake(4);

 

Preliminary R&D Lab 2 Code:

//Both motors will be set to 25% and this will go for 2 seconds, then the motors will be set to 20% power and they will run till they go 295 marks. After that the motors will both stop, reverse, and be set to run for 30% power and be run for 1.5 seconds

motorSpeed(4,25);

goFor(2);

motorSpeed(4,20);

goToAbsolutePosition(295);

brake(4);

reverse(4);

motorSpeed(4,30)

goFor(1.5);

brake(4);

 

Preliminary R&D Lab 4 Code:

//Both motors will accelerate to 25% power in 3 seconds and run for 1 second after that. The the motors will be set to 20% and run for 2 seconds. Both motors will then brake, reverse, and be set to 25% power and run for 2 seconds, then both motors will be cut off.

celerate(4,0,25,3);

goFor(1);

motorSpeed(4,20);

goFor(2);

brake(4);

reverse(4);

motorSpeed(4,25);

goFor(2);

brake(4);

 

Advanced R&D – Motor Configuration:

Motor Configuration 1 – 2 in the back

//Both motors at 35% power for 4 seconds.

motorSpeed(4,35);

goFor(4);

Motor Configuration 2 – 2 in the “front”

//Both motors at 35% power for 4 seconds but in reverse.

reverse(4);

motorSpeed(4,35);

goFor(4);

Motor Configuration 3 – One in front and back

//Both motors at 35% power for 4 second but in opposite directions.

 

reverse(1);

motorSpeed(4,35);

goFor(4);

 

Performance Test 1

//AEV to gate

 reverse(4);

 motorSpeed(4,35);

 goToAbsolutePosition(-249);

 

 brake(4);

 reverse(4);

 motorSpeed(4,40);

 goFor(1);

 brake(4);

 goFor(8);

 

Performance Test 2

//AEV to gate

 reverse(4);

 motorSpeed(4,35);

 goToAbsolutePosition(-249);

 

 brake(4);

 reverse(4);

 motorSpeed(4,40);

 goFor(1);

 brake(4);

 goFor(8);

 

 //After gate towards cabosse loading zone

 reverse(4);

 motorSpeed(4,40);

 goFor(2.2);

 brake(4);

 

 goToAbsolutePosition(-570);

 reverse(4);

 motorSpeed(4,30);

 goFor(.4);

 

 //Waiting after attaching caboose

 brake(4);

 reverse(4);

 goFor(7);

 

Final Performance Test

//AEV to gate

 reverse(4);

 motorSpeed(4,35);

 goToAbsolutePosition(-249);

 

 brake(4);

 reverse(4);

 motorSpeed(4,40);

 goFor(1);

 brake(4);

 goFor(8);

 

 //After gate towards cabosse loading zone

 reverse(4);

 motorSpeed(4,40);

 goFor(2.2);

 brake(4);

 

 goToAbsolutePosition(-570);

 reverse(4);

 motorSpeed(4,30);

 goFor(.4);

 

 //Waiting after attaching caboose

 brake(4);

 reverse(4);

 goFor(7);

 

 //With caboose towards gate

 reverse(4);

 motorSpeed(4,40);

 goToRelativePosition(212);

 

 brake(4);

 reverse(4);

 motorSpeed(4,40);

 goFor(1.25);

 

 //Waiting at gate with caboose

 brake(4);

 reverse(4);

 goFor(8);

 

 //Returning to starting point with caboose

 motorSpeed(4,40);

 goToAbsolutePosition(-250);

 brake(4);

 reverse(4);

 goFor(1.5);

 motorSpeed(4,40);

 goFor(.9);

 brake(4);