B. Week 2 (Intro to Coding)

In Week 2, students were introduced to basic Arduino coding via the AEV controller and and ran reflective sensors tests. The controller features an Arduino Nano micro-controller and two motor chips. The Nano controls the motor speed and records system data while the motor chips execute the functions of the nano.

Students ran exercise one, which introduced programming basics. Arduino language was coded and used to operate two motors, which were mounted off the ground and connected to the micro-controller.

In the first scenario, 19 lines of arduino code were written as follows:

SCENARIO 1

//accelerates motor 1 – 0->15% for 2.5seconds
celerate(1,0,15,2.5);
//runs initialized motor for 1 second
goFor(1);
//brakes motor 1
brake(1);
//accelerates motor 2 from start to 27% for 4secs
celerate(2,0,27,4);
//runs state of motors for 2.7 secs
goFor(2.7);
//declerates motor 2 from 27 to 15 in a second
celerate(2,27,15,1);
//Brake motor 2
brake(2);
//Reverse motor 2
reverse(2);
//Accelereate all 4 from start to 31%
celerate(4,0,31,2);
//All motors at 35% for one second
motorSpeed(4,35);
goFor(1);
//brakes motor 2
brake(2);
// Motor one goes for 1 second
motorSpeed(1,35);
goFor(3);
// Brakes 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(2,19);
motorSpeed(1,19);
goFor(2);
//Decelerate both motors to 0% power in 3 seconds.
celerate(2,19,0,3);
celerate(1,19,0,3);
//Brake all motors.
brake(1);
brake(2);

Next, scenario two was coded and ran for testing reflectance sensors. Due to the AEV having not been constructed yet, the code will have to be tested in Week 3. The code is as follows:

SCENARIO 2

//Run all motors at a constant speed of 25% power for 2 seconds.
motorSpeed(4,25);
goFor(2);
//Run all motors at a constant speed of 20% and using the goToAbsolutePosition
//functiontravel a total distance of 12 feet (from the starting point). You will actually
//rotate the wheel by hand (since you are on the desktop tracks) until the wheel has
//completed the required distance and the motors stop.
motorSpeed(4,20);
goToAbsolutePosition(295.38);
//Reverse motors.
reverse(4);
//Run all motors at a constant speed and 30% power for 1.5 seconds.
motorSpeed(4,30);
goFor(1.5);
//Brake all motors.
brake(4);

Overall, exercise one was executed well. The electric motors rotated smoothly and began properly at the start of the program. Little resistance or interference was observed when rotating at low speeds. Brakes were sharp, and acceleration was smooth. Even when one of the motors was shut off, the second continued to operate correctly.