servo.ino 966 B

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