Thread: Switch help
View Single Post
  #7   Spotlight this post!  
Unread 22-01-2014, 11:13
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Switch help

Sure sounds to me like a snail cam based shooter mechanism with a limit switch for the 'cocked' position.

The pseudo-code for what you're looking for looks a little something like this:

Code:
if(camLoadedSwitch = on){
camMotor.setSpeed(0);
}

if(oldTriggerState = off AND currentTriggerState = on){
camMotor.setSpeed(1);
}
oldTriggerState = currentTriggerState;
That would start the motor on a rising edge of the trigger, and stop it when it hits the limit switch, assuming this code is in a function that's called periodically.
Reply With Quote