Lab 9 Arduino Code

9Code 1:

reflectanceSensorTest(); //Tests proper function of reflectance sensors

reverse(4);   //Reverse polarity of all motors

motorSpeed(4,30); //Run all motors at 30% power

goToAbsolutePosition(335);   //Execute previous function until 13.61 ft from starting point

reverse(4);      //Reverse polarity of all motors

motorSpeed(4,40);   //Run all motors at 40% power

goFor(1.5); //Execute previous function for 1.5 seconds

//brake(4);      //Remove power from all motors

motorSpeed(4,0); //Run all motors at 0% power

goFor(8); //Execute previous function for 8 seconds

reverse(4); //Reverse polarity of all motors

motorSpeed(4,30); //Run all motors at 30% power

goToAbsolutePosition(750);   //Execute previous function until 30.47 ft from starting point

reverse(4);      //Reverse polarity of all motors

motorSpeed(4,40);   //Run all motors at 40% power

goFor(1); //Execute previous function for 1 second

//brake(4); //Remove power from all motors

motorSpeed(4,0); //Run all motors at 0% power

goFor(5); //Execute previous function for 5 seconds

motorSpeed(4,50);    //Run all motors at 50% power

goFor(2); //Execute previous function for 2 seconds

motorSpeed(4,35); //Run all motors at 35% power

goToAbsolutePosition(375); //Execute previous function until 15.23 ft from starting point

reverse(4);     //Reverse polarity of all motors

motorSpeed(4,45);   //Run all motors at 45% power

goFor(1); //Execute previous function for 1 second

motorSpeed(4,0); //Run all motors at 0% power

goFor(7); //Execute previous function for 7 seconds

motorSpeed(4,30);    //Run all motors at 30% power

goFor(2); //Execute previous function for 2 seconds

motorSpeed(4,35); //Run all motors at 35% power

goToAbsolutePosition(0); //Execute previous function until 0 ft from starting point

reverse(4);     //Reverse polarity of all motors

motorSpeed(4,45);   //Run all motors at 45% power

goFor(1); //Execute previous function for 1 second

brake(4); //Remove power from all motors

 

Code 2:

reverse(4);    //Reverse polarity of all motors

celerate(4,0,50,2); //Accelerate all motors from 0% to 50 % in 2 seconds

motorSpeed(4,50); //Run all motors at 50% power

goFor(3); //Execute previous function for 3 seconds

motorSpeed(4,0); //Run all motors at 0% power

goToAbsolutePosition(335); //Execute previous function until 13.6 ft from starting point

reverse(4); //Reverse polarity of all motors

motorSpeed(4,40); //Run all motors at 40% power

goFor(1.5); //Execute previous function for 1.5 seconds

motorSpeed(4,0); //Run all motors at 0% power

goFor(8); //Execute previous function for 8 seconds

 

Motor Warm Up:

celerate(4,0,50,10); //Accelerate all motors from 0% to 50% in 10 seconds