← All exercises

Long Press

medium

Fire a single-scan pulse when the input is released after being held continuously for at least 2 seconds — short taps produce no output.

What it teaches

Combines a hold-time timer (TONR) with falling-edge detection on the input, gated by whether the timer reached preset before release. The action fires on release only when the hold qualified — the canonical mobile/UI long-press semantic. Teaches edge detection, timer threshold gating, and conditional event-on-release logic.

Inputs and outputs

TagTypeDefaultDescription
In_ButtonBOOLPush button input
Out_PulseBOOLHigh for one scan when button is released after a long press

Required behavior

  • Out_Pulse fires for one scan when In_Button transitions from 1 to 0 after being held at 1 for at least 2000ms.
  • Out_Pulse remains 0 if In_Button is released before 2000ms of continuous hold.