Having just read walters post, it seems to me I need a timer, that when it fires it runs the code now in the button_2 press. It would run the code everytime the timer condition is met? Then the button code needs a check for if getdata is 1 or 0. so really the code is inside an if_then.

Then the timer is my event.

BTW, if the code I posted makes no sense, my appalogies.

How to setup the timer for every 50 ms?