So, I’m trying to really automate as much as a can in driver control, and here is a way im doing it.
I want to make it so that if L1 is pressed and released (ex, hitting the spacebar) my indexer (piston) will shoot out and back in. So basically when I press the button, my indexer fires and reloads in one swift motion, basically making my indexer semi automatic.
Im pretty sure Ive got this down here
if(Controller1.ButtonL1.pressing() && diskRecognized && indexerCount == 0){
Indexer.set(true);
waitUntil(!Controller1.ButtonL1.pressing());
indexerCount = 1;
}
if(indexerCount == 1){
Indexer.set(false);
indexerCount = 0;
}
definitions
diskRecognized is if a distance sensor reads that there is a disk in the disk reserve.
indexerCount is just a variable that I can change from 1-10 (or more)
Theoretically, this should do the trick for semi auto firing, but I want to go more complex
I want to make it so that if I hold this same button (L1) the indexer will do the action above, but infinitely, as long as the button is being held. This is basically an automatic firing control. To do this, I threw together this code and I wanted to see if it would work-
//full auto
while (Controller1.ButtonL1.pressing() && FAindexerCount ==0){
Indexer.set(true);
wait(0.2, sec);
Indexer.set(false);
wait(0.2, sec);
Indexer.set(true);
wait(0.2, sec);
Indexer.set(false);
wait(0.2, sec);
Indexer.set(true);
wait(0.2, sec);
Indexer.set(false);
wait(0.2, sec);
FAindexerCount = 1;
if(FAindexerCount == 1){
FAindexerCount = 0;
}
}
would this work? if not, can I get some pointers? thanks!