Help editing code for my Infrared trip wire

First off, I am very new to using the arduino and this project is a little complicated for me to edit.

I have been trying to edit a sketch I found for using a garage door safety beam as a trip wire.

I have been trying to make it work with my electric rat trap.

Ive been having trouble with rats and squirrels in my garden shed and I have made a rat trap using a 2200 volt transformer from a microwave, some strips of metal lath to carry the current and originally I used a motion detector from an old outside light to trip it. It worked great other than it would kick on for the minimum 5 seconds, which is much longer than necessary. It ends of catching the rodent on fire and then the fire keeps tripping the motion sensor causing it to continually feed this thing 2200 volts..... Which is no good.
( I got a video if anyone want to see it :wink: )

So with that set up not working as I wanted, I figured I would try my hand at using the arduino and the garage door sensors.
I managed to edit the program that I could get it to trigger my relay (that turns on the transformer) for 2 seconds, then got it to "delay(10000);" to give it time to fall off the trap...
But if the rodent is stuck blocking the beam, the arduino will read the blocked signal beam and trigger the transformer again.

What I want to do and am having a hell of a time figuring out is this:

If the rodent trips the beam, I want the program to trigger the transformer for 2 or 3 seconds, then wait 10 seconds before checking if the signal is interrupted. (that is no issue)
Here's the issue:
I need the arduino to check after the 10 seconds and see if the beam is broken or not. If it is still broken I need it to wait another 10 seconds or so and check again if it is still broken or not.
If not broken, it resets itself to the beginning of the loop and waits for it to be triggered again.

I can get the sketch to wait then start up again.... I just cant figure out how to write something that will make it wait till the beam is clear again before resetting itself.

I hope I dont sound lazy and looking for a hand out but I have been at this more than a week, watching as many tutorials on youtube as I can but as I am learning and learning, I haven't gotten to the tutorials that cover anything resembling this yet. And every day that passes, the squirrel in my shed is getting closer and closer to having babies, that I will have to contend with also, if I dont get this trap set up soon.

So if anyone is able to help me out a bit here, I would be forever greatful

I will attach the original sketch that I started with to use the garage door sensors

Cheers
Geoff

#define PHOTO_GATE_INPUT_PIN 10

#define ALARM_OUTPUT_PIN 13 

#define TONE_OUTPUT_PIN 8

#define TIMEOUT_US 10000



void setup()

{

pinMode(PHOTO_GATE_INPUT_PIN, INPUT);

pinMode(ALARM_OUTPUT_PIN, OUTPUT);

pinMode(TONE_OUTPUT_PIN, OUTPUT);

digitalWrite(ALARM_OUTPUT_PIN, LOW);

} 



void loop()

{

if (0 == pulseIn(PHOTO_GATE_INPUT_PIN, LOW, TIMEOUT_US)) 

{

digitalWrite(ALARM_OUTPUT_PIN, HIGH);



int count = 4;

while(count--)

{

tone(TONE_OUTPUT_PIN, 1000);

delay(500);

tone(TONE_OUTPUT_PIN, 800);

delay(500);

}

}



else

{

digitalWrite(ALARM_OUTPUT_PIN, LOW);

noTone(TONE_OUTPUT_PIN);

}

}

Welcome to the Forum. I think there are a lot of people here that don't want to be an accessory to a tragic electrocution. How do you keep this arrangement safe for humans?

Please read these two posts:

General Guidance and How to use the Forum
and
Read this before posting a programming question ...
You may also find useful information that would answer your question here:
Useful links - check here for reference posts / tutorials

It is important to provide as much of the information that is needed to solve your problem as you can, in your first posts. The forum link above has guidelines for posting in a standard way that makes it easiest for people to provide you with useful answers. Making an effort to do this will greatly increase the number and quality of helpful responses that you get.

In this case, the problem is that you have added your sketch as an attachment. Unless the sketch is too large, it's better if you post your code (using code tags!), rather than attach it. When it's attached, we have to download it, create a folder then open your code in our IDE. And afterwards, the folder remains unless we navigate to the "Temp" folder and manually remove it. It's much easier to just view the code in your post.
Please edit your post and insert your code inside it, using code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons. The "Code: [Select]" feature allows someone to select the entire sketch so it can be easily copied and pasted into the IDE for testing.

I edited my post to include the sketch but I don't think I did it right.
I cant seem to figure out the "code tag"

I just placed it at the bottom of my post

stuccoman:
I edited my post to include the sketch but I don't think I did it right.
I cant seem to figure out the "code tag"

I just placed it at the bottom of my post

Thanks for the help.
I believe I have it right now

aarg:
Welcome to the Forum. I think there are a lot of people here that don't want to be an accessory to a tragic electrocution. How do you keep this arrangement safe for humans?

Please read these two posts:

General Guidance and How to use the Forum
and
Read this before posting a programming question ...
You may also find useful information that would answer your question here:
Useful links - check here for reference posts / tutorials

It is important to provide as much of the information that is needed to solve your problem as you can, in your first posts. The forum link above has guidelines for posting in a standard way that makes it easiest for people to provide you with useful answers. Making an effort to do this will greatly increase the number and quality of helpful responses that you get.

In this case, the problem is that you have added your sketch as an attachment. Unless the sketch is too large, it's better if you post your code (using code tags!), rather than attach it. When it's attached, we have to download it, create a folder then open your code in our IDE. And afterwards, the folder remains unless we navigate to the "Temp" folder and manually remove it. It's much easier to just view the code in your post.
Please edit your post and insert your code inside it, using code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons. The "Code: [Select]" feature allows someone to select the entire sketch so it can be easily copied and pasted into the IDE for testing.

I keep my setup safe for humans by mounting it 10 feet up the wall in my shed. The only way anyone can get to it is by using a ladder. Trust me, I don't want to kill anyone, nor do I want to spend 8 years in jail for involuntary manslaughter