Widgets/Transformer

Counter Widget

Counter Widget

A "Transformer" type widget. Counter Widget provides a simple way to count events or create numerical sequences. It maintains an internal counter that can be incremented or decremented by a configurable amount each time it receives an event.

 

Inputs

  • in (DataType: Anything) The main input port that triggers the counter. Any incoming event will cause the counter to update its value based on the increment setting.

  • reset (DataType: Anything) Resets the counter back to 0. Any data type can trigger the reset.

  • increment (DataType: Number) Dynamically sets the increment value. The counter will use this value for subsequent counts. This can be:

    • A positive number to count up
    • A negative number to count down
    • A decimal number for fractional increments
      • Unless set through the increment port, default increment is 1.

Outputs

  • output (DataType: Number) Outputs the current counter value after each increment.

 

Examples

Basic Counter

This example shows a basic counter that increments by 1 each time it receives an event:


Drag the example onto the workspace to explore and experiment!



In this example:

  1. The Clock widget generates events every second
  2. The Counter widget increments by 1 for each event

 

Dynamic Increment Counter

This example demonstrates how to dynamically change the increment value:


Drag the example onto the workspace to explore and experiment!



In this example:

  1. The Clock widget generates events every second
  2. The Slider widget dynamically controls the increment value (from -2 to 5)
  3. The Counter widget receives the slider's current value through the increment port
  4. Each time the Clock widget triggers an event, the Counter widget increments by the slider's current value
  5. When you change the slider value, the Counter widget immediately uses the new increment value for subsequent counts

 

📌 Additional Notes

  • The counter maintains its value until explicitly reset or the recipe is reloaded
  • Negative increments can be used to count down
  • The increment value can be changed at any time through the increment input
  • The counter outputs its value immediately after receiving an event
  • The counter value and increment are preserved when the recipe is saved