Global Variables

Is there a way to keep a “Global Variable” in grasshopper, such that it’ll be initialized to zero, and, for example, every time i’ll get 1 from Arduino it will be increment by 1 and every time ill get 0 it will be decremented by 1?

What i have tried:

(The python components simply truncated the current value via if block)

But it’s super slow

Thank you

There are a few links that might be useful to you here, covering GHPython and persistent variables. If you need global variables, as in global across the Grasshopper document(s) and Rhino, you can use the Rhino Python sticky dictionary (also covered in the links on the old Grasshopper forum).