thankyou dx, but I'm not having any luck by defining the global variable before setup.
Provided you don't also define local versions of distance, it will do what you want.
It is necessary to define local versions of distance because i need to define it via processing using the function serial.read. so you see, distance cant exist before set us because it needs to be assigned while the program is running
It seems that the variable is forgotten after it has "return[ed] to the area of code from which the function was "called"."
is this the way arduino works? does it only use a variable during an active function? if so, how can i get around this problem.
Best, arthur