RobotC Programming Question

Hi guys!

I’m trying to figure out the way to program pneumatics (in RobotC) using a latch system, so that when the driver pushes a button, the pneumatics activate and deactivate only when the button is pushed again. So far, I haven’t been very lucky. :frowning:

If you know how to do this, your help is greatly appreciated! :slight_smile:

A little bit unrelated, (but very, very important :p) have any of you used either PID or TBH code? I’m trying to optimize our launcher and would like to know how they have worked out for you, and which one is the most effective!

Thank you! :slight_smile:


This is the way most people on the forum do it. It waits until the button is released before allowing the rest of the code to run. The other way requires saving the current button to a value and then only switching the state if the button is pushed AND it wasn’t pushed last time.

task main()
    bool lastButtonState = 0;

Thank you so much! I really appreciate it. I’ll try that :slight_smile: