A Complete Last of the Arduino Codes and the Lab that they correspond to. For details regarding the creation and implementation of each code, click the lab number in the drop-down menu.
Lab 2: Arduino Programming Basics
//Program Start
motorSpeed(4,0); //Initializes both motors to be set to speed 0%
celerate(1,0,15,2.5); //accelerate motor 1 from 0 to 15% for 2.5 s
motorSpeed(1,15); //Initializes motor 1 at 15% speed
goFor(1); //runs motor 1 at 15% speed for 1 sec
brake(1); //Brake motor 1
celerate(2,0,27,4); //accelerate motor 2 from 0 to 27% for 4 s
motorSpeed(2,27); ////Initializes motor 2 at 27% speed
goFor(2.7); //Runs motor 2 at constant speed for 2.7 s
celerate(2,27,15,1); //Decelerate motor 2 to 15%
brake(2); //brakes the second motor
reverse(2); //reverses motor 2
celerate(4,0,31,2); //Accelerates both motors to 31% speed in 2 s
celerate(4,31,35,1); //Accelerates the motors to 35% power
motorSpeed(4,35); //Initializes motors at 35% speed
goFor(1); //Runs motors at 35% for 1 second
brake(2); //Brakes the second motor
goFor(3); //brakes motor 2 and keeps motor 1 running at 35% for 3 sec.
brake(4); //Brakes all motors
goFor(1); //Keeps motors stopped for 1 sec
reverse(1); //Reverse direction of motor 1
celerate(1,0,19,2); //Accelerates motor 1 from 0 to 19% power in 2 seconds
motorSpeed(1,19);
motorSpeed(2,35);
goFor(2); //Sets motor 1 to 19% and 2 to 35% for 2 seconds
motorSpeed(2,19);
goFor(2); //Sets both motors to 19% and runs for 2 seconds.
celerate(4,19,0,3); //Decelerates both motors to 0% power in 3 sec.
brake(4); //Brakes all motors.
Lab 3: Design Concepts
reverse(4);
motorSpeed(4,0); //Initializes speed of motors at 0%
celerate(4,0,25,3); //Accelerates the motors to 25% in 3 seconds
goFor(1); //Runs motors at 25% for 1 second.
celerate(4,25,20,1);
goFor(2); //Sets speed of motors from 25% to 20% and runs for 2 sec.
reverse(4); //Reverses the motors.
motorSpeed(4,20);
goFor(2); //Runs motors at 20% for 2 sec
brake(4); //Brakes all motors
Lab 4 – 7: External Sensors – Design Analysis Tool
motorSpeed(4,25);
goFor(2); //Runs motors at 25% for 2 sec
motorSpeed(4,20);
goToAbsolutePosition(394); //Sends AEV 16 feet from starting position.
reverse(4); //Reverses motors
motorSpeed(4,30);
goFor(1.5); //Runs motors at 30% speed for 1.5 seconds
brake(4); //brakes motors
Performance Test 1-3:
reverse(4);
motorSpeed(4,35);
goFor(2); //Runs motors at 25% for 2 sec
motorSpeed(4,30);
goToAbsolutePosition(400); //Sends AEV 16 feet from starting position.
reverse(4); //Reverses motors
motorSpeed(4,30);
goFor(1.5); //Runs motors at 30% speed for 1.5 seconds
brake(4); //brakes motors
motorSpeed(4,0);
goFor(7);
reverse(4);
motorSpeed(4,30);
goToRelativePosition(408);
brake(4);
goFor(3);
reverse(4);
motorSpeed(4,25);
goFor(8);
Final Arduino Code:
reverse(4);
motorSpeed(4,35);
goFor(2); //Runs motors at 25% for 2 sec
motorSpeed(4,30);
goToAbsolutePosition(375); //Sends AEV 16 feet from starting position.
reverse(4); //Reverses motors
motorSpeed(4,30);
goFor(1.8); //Runs motors at 30% speed for 1.5 seconds
brake(4); //brakes motors
motorSpeed(4,0);
goFor(10);
reverse(4);
motorSpeed(4,30);
goToRelativePosition(240);
reverse(4);
goFor(3.3);
motorSpeed(4,0);
goFor(7);
motorSpeed(4,32);
goToRelativePosition(-353);
reverse(4);
motorSpeed(4,35);
goFor(2);
motorSpeed(4,0);
goFor(8);
reverse(4);
motorSpeed(4,30);
goToRelativePosition(-375);
reverse(4);
motorSpeed(4,30);
goFor(1);