servo.ino 1021 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. Servo Logic Code
  3. This script handles logic related to servo operations
  4. */
  5. //Calibrated offset to add or reduce for this particilar machine
  6. const int servoAlignmentOffset = 0;
  7. //Quickily push the switch back
  8. void pushSwitchNow() {
  9. pushSwitchDelayed(1000, 1000);
  10. }
  11. //Push switch back with delay
  12. void pushSwitchDelayed(int coverDelay, int pusherDelay) {
  13. servoCoverPusher.write(90);
  14. delay(coverDelay);
  15. servoSwitchPusher.write(130 + servoAlignmentOffset);
  16. delay(pusherDelay);
  17. servoCoverPusher.write(0);
  18. servoSwitchPusher.write(0);
  19. }
  20. //Push with a pause before the switch is pushed
  21. void pushWithHesitation(){
  22. servoCoverPusher.write(90);
  23. delay(1000);
  24. servoSwitchPusher.write(90 + servoAlignmentOffset);
  25. delay(2000);
  26. servoSwitchPusher.write(130 + servoAlignmentOffset);
  27. delay(2500);
  28. servoCoverPusher.write(0);
  29. servoSwitchPusher.write(0);
  30. }
  31. //Set the pusher servo to arm installation position
  32. void setSwitchToInstallPosition(){
  33. servoSwitchPusher.write(125 + servoAlignmentOffset);
  34. }