Arduino Code History Team N

 ⚙ Arduino Code History ⚙

Listed below are all of the codes that Team N used throughout their progression of the AEV project. Comments have been included with the code to help others to better understand what the corresponding action to the code looked like. A code glossary can be found under Team N’s menus for a better understanding of the commands and their basic functions!


The PrgrmBasics Arduino code was used to complete activity 1 in the preliminary R&D.  The purpose of this activity was to familiarize ourself with the ins and outs of Arduino code.

PrgrmBasics

//acc from 0 to 15% in 2.5 seconds

 celerate(1,0,15,2.5);

 // Run motor one at a constant speed (15% power) for 1 second.

 motorSpeed(1,15);

 goFor(1);

 // Brake motor one.

 brake(1);

 //Accelerate motor 2 from 0 to 27% in 4 seconds

 celerate(2,0,27,4);

 //run motor speed at 27% for 2.7 seconds

 motorSpeed(2,27);

 goFor(2.7);

 //Decelerate motor 2 to 15% in 1 second

 celerate(2,27,15,1);

 //Brake motor 2

 brake(2);

 //reverse the direction of motor 2

 reverse(2);

 //Accelerate all motors from start to 31% power in 2 seconds

 celerate(4,0,31,2);

 //Run all motors at a constant speed of 35% power for 1 second

 motorSpeed(4,35);

 goFor(1);

 //Brake motor two but keep motor one running at a constant speed (35% power) for 3 seconds.

 brake(2);

 motorSpeed(1,35);

 goFor(3);

 //Brake all motors for one second

 brake(4);

 goFor(1);

 //Reverse the direction of motor one.

 reverse(1);

 //accelerate motor one from start to 19% power over 2 seconds

 celerate(1,0,19,2);

 //run motor two at 35% power while simultaneously running motor one at 19% power for 2 seconds

 motorSpeed(2,35);

 goFor(2);

 motorSpeed(1,19);

 goFor(2);

 //run both motors at a constant speed (19%power) for 2 seconds

 motorSpeed(4,19);

 goFor(2);

 //decelerate both motors to 0% power in 3 seconds

 celerate(4,19,0,3);

 //brake all motors

 brake(4);


The ExternalSensorsOutside Arduino code was made and used in activity 2 of the preliminary R&D.  This code was used to familiarize ourselves with the ideas of using marks to control the distance the AEV traveled.

ExternalSensorsOutside

//Run all motors at a constant speed of 25% power for 2 seconds

 motorSpeed(4,25)

 goFor(2)

 //Run all motors at a constant speed of 20% and travel 12 feet using the goToAbsolutePosition function

 motorSpeed(4,20);

 goToAbsolutePosition(70.2);

 //Reverse motors

 reverse(4);

 //Run all motors at a constant speed of 30% power for 1.5 second

 motorSpeed(4,30);

 goFor(1.5);

 //Brake all motors

 brake(4);


The CSS1 Arduino Code was used to gather data to familiarize the team with the data analysis tool.  The data analysis tool was used to analyze data from AEV runs to make design or code improvements.

CSS1

//Accelerate all motors at a constant speed of 25% for 2 seconds

celerate(4,0,25,3);

//run all motors at a constant 25% power for 1 second

 motorSpeed(4,25);

 goFor(1);

//Run all motors at 20% power for 2 seconds

 motorSpeed(4,20);

 goFor(2);

//Reverse all motors

 reverse(4);


The AEVCoast Code was used in AR&D testing to see how coasting as a stopping method for the AEV would be efficient 0r accurate for testing in the future.

AEVCoast

//reverse direction of motors

reverse(4);

//accelerate all motors from 0-50% speed over 2 seconds

celerate(4,0,50,2);

//run motors at 50% speed for

motorSpeed(4,50);

goToRelativePostion(123.08);

//brake all motors

brake(4);


The AEVPowerBraking code was used in AR&D testing to see how efficient powering braking was in braking the system. This code (not necessarily this exact one) appeared in the team’s code throughout testing because power breaking was determined to be a more effective means of braking.

AEVPowerBraking

//reverse direction of motors

reverse(4);

//accelerate all motors from 0-50% speed over 2 seconds

celerate(4,0,50,2);

//run motors at 50% speed for

motorSpeed(4,50);

goToRelativePostion(123.08);

//reverse all motors

reverse(4);

//Backwards thrust 50% for .25 seconds

motorSpeed(4,50);

goFor(.25);


The EnergyAnalysis code was used to help acquire energy data from the AEV to show its efficiency. A simple code was created for this to just exhibit a basic energy output.

EnergyAnalysis

//run all motors at 30% for 4 seconds

motorSpeed(4,30);

goFor(4);

//run all motors at 0% for 10 seconds

motorSpeed(4,0);

goFor(10);


The PerformanceTest1 code allowed for the AEV to complete the first performance test. This performance test called for the AEV to stop at the first gate for seven seconds, and then safely pass through it once the gate was risen.

PerformanceTest1

//send AEV to gate

reverse(4);

motorSpeed(4,30);

goToAbsolutePosition(270);

//brake AEV at gate

reverse(4);

motorSpeed(4,30);

goFor(1);

//hold AEV at stop for 7 seconds at gate

motorSpeed(4,0);

goFor(7);

//continue through gate

reverse(4);

motorSpeed(4,30);

goToRelativePostion(60);


The PerformanceTest2 code allowed for the AEV to complete the second performance test. This performance test was composed of the content of performance test one, but also the AEV had to retrieve the caboose via magnetic connection, and then head back toward the gate at the center. This code allowed for such commands to be executed.

PerformanceTest2

//send AEV to gate

reverse(4);

motorSpeed(4,30);

goToAbsolutePosition(270);

//brake AEV at gate

reverse(4);

motorSpeed(4,30);

goFor(1);

//hold AEV at stop for 7 seconds at gate


The FinalPerformanceTest code was created after the development and combination of both of the previous performance tests before it. This code executed the same commands as those two performance tests, with an addition of the AEV having to travel back through the gate with the caboose attached to it, and then stopping at the initial starting point of the run.

FinalPerformanceTest

//sendoff from start

Reverse(4);

motorSpeed(4,35);

goToAbsolutePosition(267);

//brake and stop at gate

Reverse(4);

motorSpeed(4,40);

goFor(1);

//stop at gate for 7 seconds

motorSpeed(4,0);

goFor(7);

//continue to pickup point

reverse(4);

motorSpeed(4,30);

goToRelativePosition(275);

//brake and stop

reverse(4);

motorSpeed(4,40);

goFor(.5);

//stop at pickup point

motorSpeed(4,0);

goFor(5);

//sendoff from pickup point

celerate(4,45,65,3);

motorSpeed(4,65);

goToRelativePosition(-238);

//brake and stop

reverse(4);

motorSpeed(4,50);

goFor(1);

//stop at gate for 7 seconds

motorSpeed(4,0);

goFor(7);

//continue from brake

Reverse(4);

motorSpeed(4,40);

goToRelativePosition(-220);

//brake and stop

Reverse(4);

motorSpeed(4,40);

goFor(1);