One-Scan Delay
medium
Drive one lamp that follows a button instantly and a second that follows it one scan later.
What it teaches
Both lamps watch the same button: one follows it immediately, the other follows one scan later. The delay isn't a timer — it comes from order. Your program runs top to bottom every scan, so if you copy a value before the line that updates it, you copy last scan's value and end up one scan behind. That "use last scan's value" idea is the heart of edge detection, and it is why logic that looks correct can still switch a scan too early or too late.
Inputs and outputs
| Tag | Type | Default | Description |
|---|---|---|---|
| In_Button | BOOL | — | — |
| Out_Now | BOOL | — | — |
| Out_Delayed | BOOL | — | — |
Required behavior
- Out_Now turns on in the same scan In_Button turns on, and off in the same scan In_Button turns off — it follows the button with no delay.
- Out_Delayed copies In_Button but one scan later: it turns on the scan after In_Button turns on, and off the scan after In_Button turns off.