I’m trying to program a single-acting piston for my robot’s indexer. In my code, I’m trying to tell it to shoot three consecutive times, but it only shoots once and either doesn’t shoot the other two or the pressure for the other two are very weak. Attached is my code, please let me know what I’m doing wrong.
///////////////////////////////////////////////////////////////////////////////////
//AUTONOMOUS CODE
///////////////////////////////////////////////////////////////////////////////////
void autonomous(void) {
indexerPneumatic.set(true);
wait(100, msec);
indexerPneumatic.set(true);
vex::task::sleep(500);
indexerPneumatic.set(true);
wait(100, msec);
indexerPneumatic.set(true);
vex::task::sleep(500);
How pneumatics are coded is “true” extends the piston and “false” retracts the piston. Your code extends the pneumatic once, but at the second indexerPneumatic.set(true);
statement, the pneumatic is already extended so nothing happens. You need to set it to false and add a delay after before you can extend it again 
4 Likes
Maybe it’s the piston that I’m using, but with the indexerPneumatic.set(true)
code makes the piston go in and out. I tried adding indexerPneumatic.set(false)
afterwards to make it go back in, but it only successfully shot out once and either weakly shot out (it hardly moved) or didn’t shoot out at all. I’ve made sure the PSI is high and the tubes are connected, and I also tried the same code with another piston in a different three wire port, but I still got the same results.
Using .set(true); should not make it go in and out again. Something maybe wrong with your solenoid. Also, I don’t know why you are using vex::task::sleep when a wait is perfectly fine.
2 Likes