All exercises

Toggle Output

Toggle a boolean output state on the rising edge of a button input.

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.

Edge Cases

  • Handle the initial scan where the input might already be at 1.

Constraints

  • The transition must be detected within a single scan cycle.

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.