Arduino Programming Basics

Learning Arduino Programming Basics had Team D write a code collectively that would allow the team to learn the basics of coding for the AEV as well as to test to see how well the AEV interacts when code has been applied to it. In addition, not only did the lab allow the team to learn about coding the AEV and the Arduino, but it allowed the team to learn the setup of the AEV as well. Team D completed this lab by learning the right codes to input into the Arduino and then running those codes to see if they made the AEV do something.

For a list of functions used in the Arduino:


#-motor number(4=all)

I – Initial Percent Speed

F- Final Percent Speed

t- time to get to speed



motor 1 will go from 0 – 10% in 8 seconds


#-motor number(4=all)

S-percent speed



All motors will go at 30% power


t-time to go for



makes the motors go for 5 seconds


#-motor number(4=all)



motor 1 brakes


#-motor number(4=all)



motor 1 is in reverse


m-number of marks

(1 mark = 0.4875 inch)



The AEV will go to 4.875 inches from the start.


m-number of marks


The AEV will go to 4.875 from where the AEV is.


The code that the team programmed can be found here:

Code:                            What it does:

celerate(1,0,15,2.5):   accelerate motor to 15 in 2.5 sec

goFor(1);                      initialize speed to 15% then run for 1 second

brake(1):                      brake motor 1

celerate(2,0,27,4):     accelerate motor 2 to 27 percent over 4 sec

goFor(2.7);                  initialize motor 2 to 27% and run for 2.7 sec

celerate(2,27,15,1):    decelerate motor 2 from 27% to 15% over 1 sec

brake(2):                      brake motor 2

reverse(2):                   reverse direction of motor 2 through polarity

celerate(4,0,31,2):      accelerate all motors to 31% over 2 sec

goFor(1);                      initialize all motors to 35% and run for 1 sec

goFor(3);                      brake motor 2 and run motors at their set speed (35%) for 3 sec

goFor(1);                       brake all motors and hold for 1 sec

reverse(1):                     reverse polarity of motor 1

celerate(1,0,19,2):        accelerate motor 1 to 19% power over 2 sec

goFor(2);                        set motor 1 to 19% and set motor 2 to 35% then run for 2 sec

goFor(2);                        set both motors to 19% power. Then run both motors for 2 sec

celerate(4,19,0,3):        decelerate both motors to 0% power over 3 sec

brake(4):                        brake all motors


Team D found that one of the motors did not move as expected due to the internal resistance. This resistance would only occur at low speeds, and the motors performed well when rotating at high speeds. One motor in particular had more resistance than the other, and took longer to get up to speed. While there was a slight delay in the spin up time, the motor performed just as well as the other during tests so it was deemed that the team could still use the motor. There were several commands which Group D found may limit the success of the motors. First, the braking command will not stop the AEV, just brake the motors themselves. This means that the craft will continue to travel further forward and could have problems as a result. Similar to this, reversing the polarity of the motors did start reversing almost instantly because they are brushless, but did not provide much force in the opposite direction to stop the AEV. Both of these problems could potentially be solved with a better braking system.

Team D learned that each line of code heavily depended on what the motors were doing. The motors did not start or stop running as soon as a line of code was loaded, and had some resistance before starting a new function. In addition, the group learned that when a motor was stopped, it did not mean that the craft would stop as there was nothing to brake it. This meant that each group member would need to coordinate their efforts carefully to ensure that the craft would be able to make the run on the track for the task at hand.