Patch #3: Counting on you

With the objects we know by now we can already build our own little counter:

 

pd-28

On the first button click 1 is added to 0. The result is fed back into the plus object (imagine a [ + 1] now). The next time the button is pressed, 1 is added to 1 ([1 + 1]). The result is fed back into the plus object again (imagine [ + 2]). The plus object is used as a storage for the current value.

Often, there is more than one way to achieve the same thing in Pd. Here another basic counter that uses the integer object  to store the current value:

pd-29

 

 

 

 

 

When banged, the current value comes out of the int object. Then 1 is added to it. Subsequently, the new value is stored in the int object.

 


 

Example 1: Count how often a key has been pressed.

We can combine our counter with the key object and the select object and use it to count how often the spacebar is pressed:

pd-26

 

 

 

 

 

 

 

 

 


Example 2: How often can you press the spacebar in 5 seconds?

 

pd-27