The 'write' function is probably called continuously as long as button1 is held down. If that's the case the final value of pos0 will be the same as pos1. You could add a flag so that the write function only saves to pos0 the first time it is called. Then reset the flag when the buttonup event occurs.
|