# ONS — One Shot

Source: https://rungs.dev/docs/ladder-logic/instructions/one-shot-ons

> ONS in rungs.dev makes a ladder rung true for exactly one scan on each rising edge of its input. Requires a dedicated storage BOOL per ONS instance.

Makes a rung true for exactly one scan on each rising edge of its input. Requires a dedicated storage bit per instance.

## Operands [#operands]

| Name         | Type   |
| ------------ | ------ |
| `storageBit` | `BOOL` |

## How It Works [#how-it-works]

`ONS` watches the rung condition that feeds it. The first scan the condition is true, `ONS` also passes true. On every subsequent scan — while the input stays true — `ONS` passes false. When the input drops back to false and then goes true again, `ONS` fires once more.

The rise has to happen **while the program is running**. If the input is already on when the program starts, `ONS` does not fire — to a one-shot, an input that was on from the beginning is old news, not a new press. The first pulse comes only after the input goes off and on again. ([Prescan](https://rungs.dev/docs/scan-cycle/the-scan-cycle#before-the-first-scan) sets this up before the first scan.)

```
Input  _____|‾‾‾‾‾‾‾‾|________|‾‾‾‾‾‾|___
ONS    _____|‾|_______________|‾|________
```

## Example — Counting Button Presses With `ADD` [#example--counting-button-presses-with-add]

Without `ONS`, `ADD` runs every scan the button is held, so `Count` races up many times per press:

```ladder
XIC(Button)ADD(Count,1,Count)
```

Add `ONS` so the `ADD` rung is true for exactly one scan per press:

```ladder
XIC(Button)ONS(ButtonPulse)ADD(Count,1,Count)
```

(A [`CTU`](https://rungs.dev/docs/ladder-logic/instructions/ctu) would do the same job with built-in edge detection — no `ONS` needed. Reach for `ONS` when the instruction you're driving has no internal edge detection of its own.)

> **IDEA**
>
> **Practice**
>
> Try one-shots in the [Rising Edge exercise](https://rungs.dev/exercises/rising-edge) — fire for a single scan when a button turns on.

## Common Mistakes [#common-mistakes]

- Reusing the same storage bit for multiple `ONS` instructions — each `ONS` needs its own storage tag.
- Expecting a pulse from an input that is already on at startup — the one-shot only fires on a rise it observes while scanning.

## Related [#related]

- [Counters overview](https://rungs.dev/docs/ladder-logic/instructions/counters) — built-in edge detection, no `ONS` needed
- [Bit instructions overview](https://rungs.dev/docs/ladder-logic/instructions/bit-instructions)