@ UKHeliBob, there is no input for the relay contacts to connect to.
You obviously have at least 1 pin free because you intend to use it for an interrupt, or is that not what you meant ?
Take a look at this. It is not tested because I don't have the same hardware as you, whatever that is, so I have made some assumptions.
const byte photoPin = A0;
const byte buzzerPin = 8;
byte state = 0;
unsigned long buzzerStart = 0;
unsigned long waitFiveMinsStart = 0;
unsigned long buzzerPeriod = 1000UL;
unsigned long fiveMinutePeriod = 300000UL;
void setup()
{
Serial.begin(115200);
pinMode(buzzerPin, OUTPUT);
}
void loop()
{
switch (state)
{
case 0: //do nothing until the beam is broken
if (analogRead(photoPin) <= 512) //adjust value or change to digitalRead if appropriate
{
state = 1;
digitalWrite(buzzerPin, HIGH); //turn on the buzzer
buzzerStart = millis();
}
break;
case 1: //buzzer sounds for one second
if (millis() - buzzerStart >= buzzerPeriod)
{
state = 2;
digitalWrite(buzzerPin, LOW); //turn off the buzzer
waitFiveMinsStart = millis();
}
break;
case 2: //do nothing until five minutes has elapsed
if (millis() - waitFiveMinsStart >= fiveMinutePeriod)
{
state = 0;
}
break;
}
}