Team K Code

Programming Basics:

 

See our Arduino Glossary for Arduino function calls

 

Test Check: ReflectantTest

reflectanceSensorTest();

Scenario 1: PgrmBasics

celerate(1,0,15,2.5); //1. Accelerate motor one from start to 15% power in 2.5 seconds.

motorSpeed(1,15); //2. Run Motor one at a constant speed (15% power) for 1 second.
goFor(1);

brake(1); //3. Break motor one

celerate(2,0,27,4); //4. Accelerate motor two from start to 27% power in 4 seconds.

motorSpeed(2,27); //5. Run motor two at a constant speed (27% power) for 2.7 seconds.
goFor(2.7);

celerate(2,27,15,1); //6. Decelerate motor two to 15% power in 1 second.

brake(2); //7. Brake motor two.

reverse(2); //8. Reverse direction of motor two.

celerate(4,0,31,2); //9. Accel. ALL motors from start to 31% power in 2 seconds.

motorSpeed(4,35);
goFor(1); //10. Run all motors at a constant speed of 35% power for 1 second.

brake(2);
motorSpeed(1,35);
goFor(3); //11. Brake motor two but keep motor one running at a constant speed (35% power) for 3 seconds.

brake(4); //12. Brake all motors for 1 second.

reverse(1); //13. Reverse the direction of motor one.

celerate(1,0,19,2); //14. Accelerate motor one from start to 19% power over 2 seconds.

motorSpeed(2,35); //15. Run motor two at 35% power while simultaneously running motor one at 19% power for 2 seconds.
motorSpeed(1,19);
goFor(2);

motorSpeed(4,19);
goFor(2); //16. Run both motors at a constant speed (19% power) for 2 seconds.

celerate(4,19,0,3); //17. Decelerate both motors to 0% power in 3 seconds.

brake(4); //18. Brake all motors.

//19. Save Program as (Save As: ) PrgmBasics

// And here——————————————————————————–

} // DO NOT REMOVE. end of void myCode()

______________________________________________________

Scenario 2:  ExternalSensorsOutside
motorSpeed(4,25); //Set both motors to 25% speed for 2 seconds
goFor(2);

motorSpeed(4,20); //Set both motors to 20% speed, until reaches 70.2 marks
goToAbsolutePosition(70.2);

reverse(4); //Reverse both motors.
motorSpeed(4,30); //Set both motors to 30% speed for 1.5 seconds
goFor(1.5);
brake(4); //Brake both motors

______________________________________________________

Scenario 3: CSS1

celerate(4,0,25,3); //Accelerate both motors from 0% to 25% in 3 seconds

motorSpeed(4,25); //Hold both motors at 25% speed for 1 second.
goFor(1);

motorSpeed(4,20); //Hold both motors at 20% speed for 2 seconds.
goFor(2);

reverse(4); // Reverse both motors, 25% speed for 2 seconds.

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

brake(4); //Brake both motors.


Scenario 4: Heavy Energy Use

 

motorSpeed(4,30);
goToRelativePosition(244);

reverse(4);
motorSpeed(4,46.5); //Reverse to stop at gate
goFor(1);
motorSpeed(4,0); // Stop and wait
goFor(7);
reverse(4);
motorSpeed(4,25); // GO
goFor(3);
reverse(4);
motorSpeed(4,10); //Slow down at thing
goFor(4);
motorSpeed(4,0);
goFor(6.5);
//Go after it picks up the thing
motorSpeed(4,40);
goFor(4);


Scenario 5: Final Test Code

motorSpeed(4,32);
goToRelativePosition(254);
reverse(4);
motorSpeed(4,46); //Reverse to stop at gate
goFor(1);
motorSpeed(4,0); // Stop and wait
goFor(7);
reverse(4);
motorSpeed(4,37); // GO
goFor(2.25);
reverse(4);
motorSpeed(4,18.5); //Slow down at ramp original 21.25
goFor(3);
motorSpeed(4,0); //get down to bottom
goFor(5.25);
motorSpeed(4,0);
goFor(2);
//Go after it picks up the thing
motorSpeed(4,40);
goToRelativePosition(-247); //go back to gate
reverse(4);
motorSpeed(4,65); //reverse and stop at gate
goFor(1);
motorSpeed(4,0);
goFor(7.25);
reverse(4);
motorSpeed(4,50); //go
goFor(3);
reverse(4);
motorSpeed(4,40);
goFor(2.7);