Introduction to Coding


This lab shows the basic commands and steps into coding the AEV, this is crucial because the AEV will not function properly without being told what to do. So for this lab the team was instructed on how to upload code from the Arduino program on the computer, to the AEV’s Arduino Controller. The Arduino Controller is the machine that tells the AEV what to do and when to do it, while the code is exactly what needs to be done. A list of all given commands that can be used is below listed as function calls for reference when looking at the code used in the experiment. So the team was prompted to create a code to test on the test tracks provided to see how the AEV would perform in the real world. The AEV is the vehicle being designed to ride on a monorail system. For more of information on the AEV, visit here to go to the homepage.

One issue that occured when uploading the code was when selecting the COM port in the Arduino program, which is the USB connection between the computer and the vehicle. The problem was the controller was not retrieving the code, which means that the code was being sent to the wrong USB port. This issue was fixed by selecting a different USB port on the computer. Another issue was the AEV not moving when the code started right away, because the propellers were not moving. However, this was later discovered to be normal with the propellers. This is because the propellers don’t start spinning until the motors have reached a certain power.


Code Used: 

Refer here for information on command functions.

Code Explanation
celerate(1,0,15,2.5);

goFor(1);

brake(1);

Accelerate motor one from 0% power to 15% power in 2.5 seconds, then go for 1 second at that 15% power, then stop all power to motor one.
celerate(2,0,27,4);

goFor(2.7);

celerate(2,27,15,1);

brake(2);

Accelerate motor 2 from 0% to 27% power in four seconds, afterwards keeping that 27% power for 2.7 seconds. Decelerate motor 2 from 27% to 15% in one second, then stopping the motor completely.
reverse(2);

celerate(4,0,31,2);

celerate(4,31,35,1);

goFor(1);

brake(2);

Reverse motor two so it spins the opposite direction and accelerate all motors from 0% to 31% in two seconds, then immediately accelerate again from 31% to 35% in one second before braking motor two.
goFor(3);

brake(4);

Keep motor one going at 35% for another 3 seconds before making sure both motors are not moving.
reverse(1);

celerate(1,0,19,2);

celerate(2,0,35,2);

Reverse motor one to rotate the same direction as motor two, then accelerate motor one from 0% to 19% in two seconds and maintain the same speed while motor two accelerates from 0% to 35% in two seconds.
motorSpeed(4,19);

goFor(2);

Keep all motors going at 19% for another 2 seconds.
celerate(4,19,0,3);

brake(4);

Decelerate all motors from 19% to 0% in 3 seconds and then stop all motors completely.