Arduino Code

Basic Call Functions:
______________________________________________________________________

  • // Accelerate or decelerate motor(s)
    • celerate(M,P1,P2,T);
  • // Initialize motor at percent power
    • motorSpeed(M,P);
  • // Run motor at set speed for T seconds
    • goFor(T);
  • // Brake the motors
    • brake(M);
  • // Reverse the polarity of the motor(s)
    • reverse(M);
  • // Continues previous command for the relative marks
    • goToRelativePosition(N);
  • // Continues previous command for the marks relative to overall start
    • goToAbsolutePosition(N);

Lab 01 – Programming Basics

______________________________________________________________________

Lab 02 – Reflectance Sensors

______________________________________________________________________

Lab 04 – Design Analysis Tool

______________________________________________________________________

// Track Comparison

celerlate(4,0,40,3);        //Both motors go from 0 to 40% in 3 seconds.

motorSpeed(4,40);        //Set both motors to 40%.

goFor(3);                     //Continue for 3 seconds.

reverse(4);                  //Reverse all motors.

motorSpeed(4,70);         `    //Set motors to 70%

goFor(0.5);                   //Continue for half a second.

// END

 

// Battery Analysis

motorSpeed(4,50);         //Set both motors to 50%.

goToAbsolutePosition(450);     //Go 450 marks based on first position.

reverse(4);             //Reverse both motors.

motorSpeed(4,45);        //Set both motors to 45%

goFor(5);             //Continue for 5 seconds.

reverse(4);             //Reverse both motors.

motorSpeed(4,30);         //Set both motors to 30%.

goToRelativePosition(230);    //Go 230 marks from current location.

// END

 

// FINAL AEV CODE FOR LAB TRACK

motorSpeed(4,30);

goToAbsolutePosition(224);

reverse(4);

celerate(4,0,60,1.375);

reverse(4);

motorSpeed(4,0);

goFor(7.2);

motorSpeed(4,30);

goFor(2.3);

motorSpeed(4,20);

goFor(0.5);

reverse(4);

motorSpeed(4,0);

goFor(7);

celerate(4,0,48,3);

motorSpeed(4,48);

goToAbsolutePosition(475);

reverse(4);

celerate(4,0,80,1.8);

reverse(4);

motorSpeed(4,0);

goFor(7.9);

motorSpeed(4,35);

goFor(3.45);

reverse(4);

celerate(4,0,80,1); //.9 originally

reverse(4);

 

// FINAL PERFORMANCE TEST CODE FOR CLASS TRACK (UNREFINED)

motorSpeed(4,30);

goToAbsolutePosition(210);

reverse(4);

celerate(4,0,60,1.375);

reverse(4);

motorSpeed(4,0);

goFor(7.2);

motorSpeed(4,30);

goFor(2.3);

motorSpeed(4,20);

goFor(0.5);

reverse(4);

motorSpeed(4,0);

goFor(7);

celerate(4,0,45,3);    //Edited from 50 to 45

motorSpeed(4,45);  //Edited from 50 to 45

goToAbsolutePosition(482);

reverse(4);

celerate(4,0,80,1.8);

reverse(4);

motorSpeed(4,0);

goFor(7.9);

motorSpeed(4,35);

goFor(3.45);

reverse(4);

celerate(4,0,80,0.9);

reverse(4);