Lab 02: Arduino Programming Basics was designed to teach each team how to operate their AEV using Arduino programming software. The AEV controller is made using an Arduino Nano microcontroller and two motor chips. Learning how to operate the AEV controller is essential for the completion of the AEV Project. The Arduino programming language was similar to C or C++ programming language. Although the team did not have prior knowledge of these languages, the team was able to perform the lab using functions similarly as done in MATLAB.
During this lab, the group became very familiar with the commands used to control the Arduino. The entire team learned the commands used in the code, and how to turn the AEV on using the Arduino Board. The team made the prototype AEV accelerate both forward and backward using the programming. After this lab, the team felt very confident about their basic knowledge of the Arduino coding process.
The lab was useful in teaching the team how to operate the AEV using the Arduino. The executive summary of the lab can be seen below:
Codes Used In Lab:
Code 1
//Accelerate motor one from start to 15% power in 2.5 seconds
celerate(1,0,15,2.5);
//Run motor one at a constant speed (15% power) for 1 second
goFor(1);
//Brake motor one
brake(1);
//Accelerate motor two from start to 27% power in 4 seconds
celerate(2,0,27,4);
//Run motor two at a constant speed (27% power) for 2.7 seconds
goFor(2.7);
//Decelerate motor two to 15% power in 1 second
celerate(2,27,15,1);
//Brake motor two
brake(2);
//Reverse the direction of only 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 1 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);
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);
Code 2
//Reverse all motors
reverse(4);
//Power all motors at 25% power for 0.5 second.
motorSpeed(4,25);
goFor(0.5);
//Brake all motors for 0.1s.
brake(4);
goFor(0.1);
//Repeat Steps 2&3 1 more time.
motorSpeed(4,25);
goFor(0.5);
brake(4);
goFor(0.1);
//Power all motors at 15% power for 0.3 second.
motorSpeed(4,15);
goFor(0.3);
// Brake all motors for 0.05 seconds.
brake(4);
goFor(0.05);
//Power all motors at 40% power for 0.3 second.
motorSpeed(4,40);
goFor(0.3);
//Power all motors at 25% power for 0.5 second.
motorSpeed(4,25);
goFor(0.5);
//Power all motors at 15% power for 0.3 second.
motorSpeed(4,15);
goFor(0.3);
//Brake all motors for 0.05 seconds
brake(4);
goFor(0.05);
//Power all motors at 40% power for 0.3 second
motorSpeed(4,40);
goFor(0.3);
//Power all motors at 25% power for 0.5 second.
motorSpeed(4,25);
goFor(0.5);
//Brake all motors for 0.5 seconds.
brake(4);
goFor(0.05);
//Power all motors at 55% power for 0.5 second.
motorSpeed(4,55);
goFor(0.5);
// Brake all motors for 0.1 seconds.
brake(4);
goFor(0.1);
//Power all motors at 55% power for 0.5 second.
motorSpeed(4,55);
goFor(0.5);
// Brake all motors for 0.1 seconds.
brake(4);
goFor(0.1);
//Power all motors at 65% power for a total of 0.3 second.
motorSpeed(4,65);
goFor(0.3);
//Brake all motors for 0.05 seconds.
brake(4);
goFor(0.05);
//Power all motors at 40% power for 0.3 second.
motorSpeed(4,40);
goFor(0.3);
//Power all motors at 20% power for 0.5 second.
motorSpeed(4,20);
goFor(0.5);
//Power all motors at 15% power for 0.3 second.
motorSpeed(4,15);
goFor(0.3);
//Brake all motors for 0.05 seconds
brake(4);
goFor(0.05);
//Power all motors at 40% power for 0.3 second.
motorSpeed(4,40);
goFor(0.3);
//Power all motors at 25% power for 0.5 second.
motorSpeed(4,25);
goFor(0.5);
//Brake all motors
brake(4);