Ioannis, not sure what you mean by gets one every 4th. The way I understand your statement is that you get a valid pulse once in 4 transmissions. If that is correct, the code which does that is the loops part. if loops < 3 then ..... When it finds a code 'repeated' 4 times, it transfers to the Prev_code. Is that what you're looking for??