# Programming Basics

Programing Basics was an introduction to the AEV project, more specifically the basics of programming with the Arduino Nano microcontroller and Arduino Integrated Development Editor (IDE). Using pre-developed “function calls”, as seen in the table below, codes can be written to maneuver a constructed Advanced Energy Vehicle (AEV) on a suspended track. Group F was able to become comfortable with most of the function calls and write code for the Scenario introduce, as well as, come up with conclusion about the components of the AEV. The code written for Programming Basics is linked below.

 Code Comment celerate(1,0,15,2.5); //Accelerate motor one from start to 15% power in 2.5 sec motorSpeed(1,15); //Run motor one at a constant speed (15% power) goFor(1); //go for 1 second brake(1); //Brake motor 1 celerate(2,0,27,4); ///Accelerate motor two from start to 27% power in 4 sec motorSpeed(2,27); //Run motor one at a constant speed (27% power) goFor(2.7); //go for 2.7 seconds celerate(2,27,15,1); //Decelerate motor two to 15% power in 1 second brake(2); //Brake motor 2 reverse(2); //Reverse motor 2 celerate(4,0,31,2); //Accelerate all motors from start to 31% power in 2 seconds motorSpeed(4,35); //Run all motors at 35% goFor(1); //For 1 second brake(2); //Brake motor 2 motorSpeed(1,35); //Motor 1 35% goFor(3); //for 3 seconds brake(4); //Brake all motors goFor(1); //For 1 second reverse(1); //Reverse motor 1 celerate(1,0,19,2); //Accelerate motor one from start to 19% power over 2 seconds motorSpeed(2,35); //Motor 2 35% motorSpeed(1,19); //Motor 1 19% goFor(2); //Go for 2 seconds motorSpeed(4,19); //All Motors 19% goFor(2); //For 2 seconds celerate(4,19,0,3); //Decelerate all motors to 0 in 3 seconds brake(4); //Brake all motors

In completing Programming Basics successfully many observations were made about the AEV, these observations are listed below:

When running the code, the electric motors performed as almost expected. A slight delay was noticed when rotating the propellers at the beginning of the test program, this was at low power during the initial acceleration. Further test will be conducted to try to solve the issue. It was also noted that the braking and reverse commands were not as efficient as they should be and alternatives will be tested.

Note – 1 mark = 0.4875 in

 Function Call Function Example celerate(#,I,F,t); #-motor number(4=all) I – Initial Percent Speed F- Final Percent Speed t- time to get to speed celerate(2,0,5,5); motor 1 will go from 0 – 5% in 5 seconds motorSpeed(#,S); #-motor number(4=all) S-percent speed motorSpeed(4,20); all motors will go at 20% power goFor(t); t-time to go for goFor(3); the motors go for 3 seconds brake(#); #-motor number(4=all) brake(2); motor 2 brakes reverse(#); #-motor number(4=all) reverse(1); motor 1 is in reverse goToRelativePosition(m); m-number of marks goToRelativePosition(5); the AEV will go to 2.4375 in from the start goToAbsolutePosition(m); m-number of marks goToAbsolutePosition(8); the AEV will go to 3.9 in fron where the AEV is