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
)
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);
}
}
