Arduino Programs

Preliminary R&D

PrgmBasics
  Code used in Exercise 1

celerate(1,0,15,2.5);
motorSpeed(1,15);
goFor(1);

brake(1);

celerate(2,0,27,4);
motorSpeed(2,27);
goFor(2.7);

celerate(2,27,15,1);

brake(2);

reverse(2);

celerate(4,0,35,1);
motorSpeed(4,35);
goFor(1);
brake(2);
goFor(3);

brake(4);

reverse(1);

celerate(1,0,19,2);
goFor(2);
motorSpeed(2,35);
goFor(2);

motorSpeed(4,19);
goFor(2);

celerate(4,19,0,3);

brake(4);

 

ExternalSensorsOutside
   Code used in Exercise 2

motorSpeed(4,25);
goFor(2);

motorSpeed(4,20);
goToAbsolutePosition(295);

reverse(4);

motorSpeed(30);
goFor(1.5);

brake(4);

 

CSS1
  Code used in Exercise 4

celerate(4,0,25,3);
motorspeed(4,25);
goFor(1);

motorspeed(4,20);
goFor(2);

reverse(4);

motorspeed(4,25);
goFor(2);

brake(4);

 

Advanced R&D

Motor_test
 Code used to test motor quantity

motorSpeed(4, 70);
 //initiates all motors at 50% power
goToAbsolutePosition(99);
 //continues running the motors until 99 marks have been travelled

brake(4);
 //stops the motors

 

Propeller_test
 Code used to test pushing propeller configuration

motorSpeed(4, 50);
 //initiates all motors at 50% power
goToAbsolutePosition(-99);
 //continues running the motors until 99 marks have been travelled
 //-99 was used to fix a sensor problem

brake(4);
 //stops the motors

 

Propeller_test
 Code used to test pulling propeller configuration

reverse(4);
 //reverses direction of all motors
motorSpeed(4,50);
 //initiates all motors at 50% power
goToAbsolutePosition(-99);
 //continues running the motors until 99 marks have been travelled
 //-99 was used to fix a sensor problem

brake(4);
 //stops the motors

 

Performance Testing

PT1
 Code used to complete performance test 1

reverse(4);
 //reverse initial polarity of motors
motorSpeed(1,45);
motorSpeed(2,45);
 // initialize both motors
goToAbsolutePosition(165);
 // go to bottom of the ramp
brake(1);
brake(2);
 // brake both motors
goToAbsolutePosition(316);
 // go to the gate via coasting
rotateServo(65);
 // stop with servo
goFor(1);
rotateServo(0);
 // unbrake
goFor(6);
 // end of 7 second wait for gate
motorSpeed(1,29);
motorSpeed(2,29);
 // initialize both motors to 29

 

PT2
 Code used, in addition with PT1, to complete performance test 2

goToAbsolutePosition(434);
 // go to the top of the hill of loading zone
brake(4);
 // brake both motors
goFor(10);
 // wait to connect with caboose plus 5 seconds connected
reverse(4);
 // reverse polarity of motors
motorSpeed(4,55);
 // initialize both to 55

 

PT3
 Code used, in addition with PT1 and PT2, to complete performance test 3

//PT 3
goToAbsolutePosition(435);
 // go back to the top of the hill of the loading zone
brake(4);
 // brake both motors
goToAbsolutePosition(367);
 // go back to gate
rotateServo(65);
 // use servo to brake
goFor(1);
rotateServo(0);
 // unbrake
goFor(6);
 // end of 7 second wait for gate
  //lab track
  //motorSpeed(4, 55);
  // intialize both motors to 55
  // class track
motorSpeed(4, 57);
 // lab track
  //goToAbsolutePosition(275);
  // go to a little before top of hill of starting zone
 // class track
goToAbsolutePosition(270);
brake(4);
 // brake both motors
  //lab track
  //goToAbsolutePosition(55);
  // go to end of track via coasting
  //class track
goToAbsolutePosition(25);
rotateServo(65);
 // brake with the servo
goFor(1);
rotateServo(0);
 // unbrake

 

Final_PT
 Program used to complete final performance test

// PT1
reverse(4);
 //reverse initial polarity of motors
motorSpeed(1,45);
motorSpeed(2,45);
 // initialize both motors
goToAbsolutePosition(165);
 // go to bottom of the ramp
brake(1);
brake(2);
 // brake both motors
goToAbsolutePosition(316);
 // go to the gate via coasting
rotateServo(65);
 // stop with servo
goFor(1);
rotateServo(0);
 // unbrake
goFor(6);
 // end of 7 second wait for gate
motorSpeed(1,29);
motorSpeed(2,29);
 // initialize both motors to 29
 // PT 2
goToAbsolutePosition(434);
 // go to the top of the hill of loading zone
brake(4);
 // brake both motors
goFor(10);
 // wait to connect with caboose plus 5 seconds connected
reverse(4);
 // reverse polarity of motors
motorSpeed(4,55);
 // initialize both to 55
 //PT 3
goToAbsolutePosition(435);
 // go back to the top of the hill of the loading zone
brake(4); // brake both motors
goToAbsolutePosition(367);
 // go back to gate
rotateServo(65);
 // use servo to brake
goFor(1);
rotateServo(0);
 // unbrake
goFor(6);
 // end of 7 second wait for gate
  //lab track
  //motorSpeed(4, 55);
  // intialize both motors to 55
 // class track
motorSpeed(4, 57);
  // lab track
  //goToAbsolutePosition(275);
  // go to a little before top of hill of starting zone
 // class track
goToAbsolutePosition(270);
brake(4);
 // brake both motors
  //lab track
  //goToAbsolutePosition(55);
  // go to end of track via coasting
 //class track
goToAbsolutePosition(25);
rotateServo(65);
 // brake with the servo
goFor(1);
rotateServo(0);
 // unbrake