Programming Basics

Experimental Study Summary

In the programming basics lab, Team A grasped the functionality of the AEV’s motor, as well as coding in Arduino. The motors, as exemplified in the programming basics lab code below, did not rotate the propellers immediately, but instead jolted them into its spinning motion. While the commands provided for this lab did complete the given task, some hindrances were spotted within the group. For example, the brake command [brake()] did not stop the vehicle immediately, but gradually applied resistance to halt the AEV. Another disadvantage that was spotted during this lab was the nature of the code in relation to the project itself. As seen in the code below, it executes line-by-line, meaning multiple commands cannot be executed at a time, which hinders the way Team A can solve the issue of the AEV’s movement. Also, in regards to this experimental study, logical errors came up frequently, but were resolved as a team. One example of a logical error that came up, and that was later resolved, was the direction of the vehicle. Team A initially coded the AEV thinking that it would move forward, but when tested it moved backwards. This was fixed by flipping the motor direction in the code. Overall, Team A was able to understand the lab’s structure, and no major complaints were found to improve the programming basics lab.

Code

Arduino Code Glossary

Function Code Description Example
celerate(m,p1,p2,t); Accelerates or decelerates the specified motor (m) from the first percent of power (p1) to the second (p2) in the given amount of time (t) celerate(1,15,40,4);
Accelerates motor 1 from 15% power to 40% power in 4 seconds
motorSpeed(m,p); Sets the specified motor to the given percent of power motorSpeed(2,20);
Runs motor two at 20% power until stopped with the break command
goFor(t); Runs the motors at the current power for the given amount of time (t) goFor(3);
Runs the motors at their current power for 3 seconds
brake(m); Stops the specified motor (m) from rotating brake(1);
Stops the rotation of motor 1
reverse(m); reverses the rotation direction of the specified motor (m) reverse(4);
reverses the direction of rotation for all motors
goToRelativePosition(n); Runs the AEV at the current settings until it reaches the specified distance (n) from the vehicle’s current position. “n” is specified in marks where 1 mark = 0.4875 inches and “n” can be positive or negative (positive for forward movement, negative for backwards movement) goToRelativePosition(30);
AEV continues at it’s current settings until it moves forward 30 marks
goToAbsolutePosition(n); Runs the AEV at the current settings until it reaches “n” marks from its starting position goToAbsolutePosition(100);
AEV continues at it’s current settings until it reaches 100 marks from its starting position
reflectanceSensorsTest(); Runs a program on the computer that displays the marks being recorded by the reflectance sensors reflectanceSensorsTest();

 

Scenario Code for Programming Basics

Code Comments
celerate(1, 0, 15, 2.5); //Step 1 (Start)
motorSpeed(1, 15); //Step 2
brake(1); //Step 3
celerate(2, 0, 27, 4); //Step 4
motorSpeed(2, 27); //Step 5
goFor(2.7);
celerate(2, 27, 15, 1); //Step 6
brake(2); //Step 7
reverse(2); //Step 8
celerate(2, 27, 15, 1); //Step 9
motorSpeed(4, 35); //Step 10
goFor(1);
brake(2); //Step 11
motorSpeed(1, 35);
goFor(3);
brake(4); //Step 12
goFor(1);
reverse(1); //Step 13
celerate(1, 0, 19, 2); //Step 14
motorSpeed(2, 35); //Step 15
motorSpeed(1, 19);
goFor(2);
motorSpeed(4, 19); //Step 16
goFor(2);
celerate(4, 19, 0, 3); //Step 17
brake(4); //Step 18 (End)