Do Beep Beep with buzzer

Sorry for the subject, I couldn't think of a different way to define it....

I have a setup attached to a number of sensors. when one of them triggers i want my buzzer to do an ongoing beep beep until its associated sensor detects otherwise. What I have is a buzzer (not a piezzo). I have found the proper beep rate by using this code:

  digitalWrite(5, HIGH);
  delay(100);
  digitalWrite(5, LOW);
  delay(50);

But I can't loop there as I need to check other sensors. Is there any way to achieve this by triggering the buzzer ON, have it do its thing while checking other things and trigger it OFF when at another time?

Yea I think you can, the example "Blink With Out Delay" is a great example of this.

It basically uses a variable as a counter, and once the variable hits the set interval amount it resets. Hope it helps!

This works for me!

Thank you.