Logically, sort of. First, try to put your code into code blocks. It makes your code look nice :P They look like [code ] put your code here [/code ] without the spaces after them. Follow the above suggestions as well.
Code:
else
{
piston1extract.set (false);
piston1retract.set (false);
piston2extract.set (false);
piston2retract.set (false);
}
The above code has a logic error. When not in operation, the pneumatic cylinder should be retracted, so the solenoid that is connected to the forward most valve on the cylinder (the one closest to the functioning end) is enabled while the other is disabled. The code should look sort of like this (which is C++)
Code:
else
{
Reverse2->Set(1);
Reverse->Set(1);
Forward2->Set(0);
Forward->Set(0);
}
Here's some pseudo code / C++ that demonstrates some basic logic:
Code:
if (Button1)
{
Forward->Set(1);
Reverse->Set(0);
Wait(0.1);
}
else if (!Button1)
{
Forward->Set(0);
Reverse->Set(1);
Wait(0.1);
}
It's pretty much the same for both languages