pulseIn retuns zero every second time called

and GND are connected I suppose when you wire all this on your m0?