laser tripwire wont work

hi there,

I’m kinda mixed up and it’s been 3 hours i’m trying to figure what’s wrong… and I need a fast answer since the LARP for which i’m doing this is in 9 hours.

I’m make a laser tripwire with a 2 relay board.
What I want is that when the laser is broken, the relay get on for 20 minutes, then it goes off until beam is broken again.

My larp fellow will need to put “radioactiv” rod’s (which are aluminium rod’s) inside the tube were the beam is to be broken, then will activate relay to start the “zombie wave generator” (light and strobe)

I’ve been able to sometime activate the relay but the relay shut off in less than 2 minutes. still searching but didn’t found where I could been wrong (maybe too tired and the problem is just in front of me)

thanks a lot guy, still wish to find the answer before I start, If not, i should use my b plan

generator_v2.ino (344 Bytes)

try:

delay(1200000UL);
digitalWrite(4, HIGH);

Why are you turning the internal pullup resistor on? Pin 4 is not an output pin.

20 lines of code could easily have been posted between code tags. There was no reason to make anyone download the file.

I can not believe that you were so lazy as to not be able to properly indent 20 lines of code. If I was your instructor, I'd take points off for code that looked that crappy.

I would also expect some comments in the code, and mark down for there not being any.

I would mark down for using 0 and 1 as the arguments to digitalWrite(). You should be using HIGH and LOW CONSISTENTLY.

A programmer you are not.