How to use delay?

Hi - I’m building a project using Particle.publish() and Particle.subscribe(). It’s based on the tripwire code example for publish and subscibe in the particle docs.

https://docs.particle.io/guide/getting-started/examples/core/#the-buddy-system-publish-and-subscribe

However, when I activate the trip wire, both particles get stuck on “broken” after the first or second time tripped. I’d like to create a delay in the particle taking readings so it slows down and doesn’t get stuck, but I’m not sure how to do that of even if that’s the best way to manage the trip wire function. Can anyone help me out with suggestions as to (1) what the problem might be with the trip wire function in terms of particle.publish() and (2) How to make a solution for this? Thank you!