analog read only once a time
Store the current read value AND the previous value and check if a border has been crossed.

E.g. 

if Previous value &lt; 500 AND current value &gt;= 500
   Going from 0 to 1 -&gt; return/send 1
else if Previous value &gt;= 500 AND current value &lt; 500
   Going from 1 to 0 -&gt; return/send 0


However, to make it more complicated, you might have debouncing effects, e.g. what if the value moves for some time around 500 to go to 200... It will still result in possibly many 0 and 1 boundary changes.

You can fix this easily by using two different value: by checking going lower &lt; 490 and going higher > 510 (or any other appropriate value. Or use a debounce mechanism where it should be below or above the 500 value for a minimum (but short) amount of time.