All exercises

Toggle Output

Toggle a BOOL output on the rising edge of a button input. The rungs.dev Add-On Instruction detects edges every scan, including the very first one.

beginner

Parameters

NameTypeUsageDescription
In_ButtonBOOLInputButton input signal to monitor for a rising edge.
Out_ToggledOutputBOOLOutputOutput signal that changes state on each rising edge of the button input.

Behavior

  1. Monitor the In_Button input for a rising edge transition from 0 to 1.
  2. When a rising edge is detected, invert the current state of Out_ToggledOutput.
  3. Update the internal state of LastButtonState to match the current In_Button input at the end of each scan.
  4. The rising edge must be detected within a single scan cycle, including correct behavior on the initial scan.

Ready to start?

Open this exercise in Rungs Studio, write your solution, then click Test in the toolbar to verify your work against the built-in test cases.