Logic node

Counter

Counts boolean events up and down. Every rising edge on Count Up advances the count by Step, Count Down rewinds it, and Reset returns it to Start Value. Four limit modes — Off, Clamp, Loop, Ping-Pong — shape what happens at the boundaries, and a one-frame Carry pulse on every wrap or bounce makes counters cascade like digits on an odometer. It is the workhorse for step sequencers, scene indices, and "every Nth event" logic.

Inputs

PortTypeDefault
Count UpEach time this switches from off to on the count moves forward by one Step. An input already on at startup counts as the first event.boolfalse
Count DownEach off-to-on switch moves the count back by one Step. Fired together with Count Up on the same frame the two cancel out exactly.boolfalse
ResetAn off-to-on switch returns the count to Start Value. Held on from the very first frame it is ignored, so a stuck-on cable cannot block counting.boolfalse
Start ValueThe number the count begins at and returns to on Reset. Any whole number works, negatives included; with a limit mode active it is pulled into the Min…Max range.int0
StepHow far each event moves the count. Not bounded — 1 is the usual, larger values jump, 0 freezes the count while still passing events, and a negative value swaps the two directions.int1
LimitWhat happens at the edges: Off counts forever, Clamp stops at Min and Max, Loop wraps around, Ping-Pong bounces back. Anything outside the list behaves as Off.int0
MinThe low edge of the counting range, used by every limit mode except Off. If it ends up above Max the two simply swap, so the range is never inverted.int0
MaxThe high edge of the counting range. In Loop mode counting past it lands back on Min, in Ping-Pong it turns around, and Carry pulses for one frame each time.int10

Outputs

PortType
Countint
Carrybool
At Limitbool

How It Works

Edge semantics (the same system-wide conventions as Do Once and Integrator — everything runs per frame, so levels are not events):

  • Count Up and Count Down fire on a rising edge (false→true). An input that is already true on the very first frame counts as an edge — events pass through startup.
  • Reset re-arms on a rising edge only and ignores a startup-true input: a held-true Reset cable must not clear the counter on frame one. This asymmetry with Count Up/Down is deliberate.
  • Same frame ordering: Reset is applied first, then counting — Reset + Count Up together counts one step from the fresh Start Value. Count Up and Count Down arriving together are a deterministic net zero (both steps apply).

Limit modes:

LimitBehaviorCarry
Off (0, default)unbounded (64-bit integer, overflow wraps)never
Clamp (1)count stops at Min/Max1-frame pulse when a limit is reached or a step is cut short
Loop (2)integer wrap over the inclusive range [Min, Max] — with 0…9, stepping up from 9 lands on 01-frame pulse on each wrap
Ping-Pong (3)bounces between Min and Max; the node remembers its travel direction — Count Up advances along the current direction, Count Down rewinds against it1-frame pulse at each bounce

Loop wraps arithmetically over a span of Max − Min + 1, so a large Step that overshoots the range still lands on the mathematically correct cell. In Ping-Pong, hitting a boundary pins the count to that boundary and flips the direction. Min and Max are order-independent (sorted internally), and if you tighten the range live while a limit mode is active, the count is pulled back inside it immediately.

Outputs. Count is the current value. Carry is a strict one-frame pulse emitted on wrap, bounce, or clamp hit — the cascading hook (seconds → minutes, or "every N events do X"). At Limit is a level: true for as long as the count sits exactly at Min or Max while a limit mode is active.

State lifecycle. The count, ping-pong direction, and edge memories are volatile — never saved with the project. Loading a project restarts the counter at Start Value. Deleting the node discards its state.

Inspector. The Limit row is a dropdown (Off / Clamp / Loop / Ping-Pong). The Reset row shows a "Reset Now" button — usable alongside a wired Reset cable — plus a live readout of the current count. Min and Max are hidden while Limit is Off (unless connected); connected ports are never hidden.

Parameters in Depth

Count Up (bool, default false) — rising edge adds Step. Float cables count as true above 0.5, so beat probabilities and gate signals work directly.

Count Down (bool, default false) — rising edge subtracts Step (in Ping-Pong: rewinds against the current travel direction).

Reset (bool, default false) — rising edge returns the count to Start Value and resets the ping-pong direction to upward. Applied before counting within the same frame. Startup-true is ignored.

Start Value (int, default 0) — the value at node creation and after any Reset (including the inspector button). It is resolved live, so a connected Start Value takes effect at the next reset.

Step (int, default 1) — the amount added/subtracted per edge. Larger steps let one event skip multiple cells; negative steps invert the counting directions.

Limit (int, default 0 = Off) — 0 Off, 1 Clamp, 2 Loop, 3 Ping-Pong (see table above).

Min (int, default 0) / Max (int, default 10) — the inclusive boundary values for Clamp/Loop/Ping-Pong. Swapped automatically if entered in reverse. In Loop mode the count occupies every integer from Min through Max before wrapping.

Outputs: Count (int), Carry (bool, 1-frame pulse), At Limit (bool, level).

Use Cases

  • Beat-driven step sequencer: Audio Beat Detection (Kick) → Counter (Limit: Loop, Min 0, Max 7) → Switch (Index) cycles eight color or shape variants in time with the music.
  • Every Nth beat: Counter (Loop 0…3) counting kicks, with Carry → Do Once → a one-shot flash — the Carry pulse fires exactly once per full lap, turning "every beat" into "every 4th beat".
  • Cascaded odometer: LFO (Trigger, 1 Hz) → Counter A (Loop 0…59) whose Carry → Counter B (Count Up) builds a seconds/minutes pair; Counter B → Text as Image → Canvas displays it.
  • Manual scene stepping: Keyboard (one key → Count Up, another → Count Down) → Counter (Clamp 0…5) → Switch (Index) pages through looks in a live set, with At Limit → UI Text signalling "first/last scene".
  • Ping-pong chase: Timer (Done, Loop on) → Counter (Ping-Pong, 0…9) → Math (divide by 9) → Canvas (Position X) marches an element left-to-right and back, one discrete cell per timer cycle.
  • Event budget: OSC Receiver (bool) → Counter (Clamp, Max = allowed count) with At Limit → Logic (NOT) gating further triggers — a rate-limiting pattern for external control.

Tips

  • Counter is strictly event-driven: a held true input counts once, not continuously. To count "while held", use an Integrator in Per Second mode instead.
  • Carry lasts exactly one frame. Anything consuming it must run every frame — feeding it into another Counter, Do Once, or Integrator (On Trigger) is the intended pattern; polling it at a slower rate can miss pulses.
  • In Clamp mode a step that overshoots (Step 5 into a wall 2 away) still pulses Carry when it gets cut short — useful for detecting "tried to go past the end".
  • Use the same clock for related counters. Two counters fed by different triggers drift apart; cascade with Carry instead of duplicating triggers.
  • The count is volatile — a project load restarts at Start Value. Persist a value across sessions with Set Variable / Get Variable if needed.
  • Related nodes: Integrator (continuous accumulation with the same limit-mode family), Do Once (a single-shot gate instead of a count), Switch (the natural consumer of Count as an index), Timer (time-based rather than event-based progression).

Open Counter in the interactive catalog →

Counter is one of 381 nodes in Grafit Pro.

Free download. Every feature for 7 days, no card. Then €99.99 once — or keep playing your projects as a Player.

More Logic nodes