Arduino Codes Lab 1

Appendix

 

Arduino Code

 

//begin to accelerate motor1 from start to 15% power in 2.5 sec

celerate(1,0,15,2.5);

// constant speed for motor1

 motorSpeed(1,15);

//hold one for 1 sec

 goFor(1);

//brake motor one

 brake(1);

// accelerate motor2 from start to 27% power in 4 sec

 celerate(2,0,27,4);

//constant speed for motor one

 motorSpeed(2,27);

// hold one for 2.7 sec

 goFor(2.7);

//brake motor2

 brake(2);

//reverse direction of only motor2

 reverse(2);

//accelerate all motors from start to 31% power in 2 sec

 celerate(4,0,31,2);

//constant speed 35% for all

 motorSpeed(4,35);

//hold for 1 sec

 goFor(1);

//brake motor two

 brake(2);

//keep motor one running at a constant speed

 motorSpeed(1,35);

//hold for 3 sec

 goFor(3);

//brake all motors

 brake(4);

//hold for one sec

 goFor(1);

//reverse direction of motor one

   reverse(1);

//accelerate motor1 from start to 19% power over 2 sec

   celerate(1,0,19,2);

//run motor2 at 35%

   motorSpeed(2,35);

   //goFor(2);

//run motor1 at 19%

   motorSpeed(1,19);

//hold for 2 sec

   goFor(2);

// run both motors at constant speed 19%

   motorSpeed(4,19);

//hold for 2 sec

   goFor(2);

//decelerate both motors to 0% in 3 sec

   celerate(4,19,0,3);

//brake all motors

   brake(4);