Help making a controller

Hello, I've just purchased an Arduino Duemilanove about a week ago to control a Halloween prop I'm making and I'm no programmer! I've been reading the sections; getting started, playground, tutorials and such but I'm just not getting it fast enough so now I'm getting nervous. I can write down what I want to do in English. Would someone be willing to look at my statement and please help me program it? I need to test it all out before Halloween so I'm feeling really rushed. Thank you.

/*
2011
Control of a Halloween Graveyard through a 8-Relay card.


Arduino Duemilanove for controller

Relay card here: http://arduino-direct.com/sunshop/index.php?l=product_detail&p=156

SENSOR-1
An IR Barrier Switch is the sensor. When activated it provides 9VDC to a buzzer.
I have removed the buzzer and installed a LM7805CT to bring the 9VDC down
to 5VDC to act as an input the Arduino can handle.

AUDIO-1,2,3,4
Sound card has 4 push buttons for 4 sounds so a CLOSED relay would = on

AIR VLV-1,2
Two 24VAC solonoid valves will activate two pneumatic props, so a CLOSED
relay would allow a power on condition and air to flow.

LIGHTS-1
An electric prop, 9VDC series of lights, needs an on, so a CLOSED relay would = on
*/

SETUP
// turn everything off but the background noises
RELAY-1 = ON //AUDIO 1 = AMBIENT SOUND, needs to be able to loop when nothing else runs
RELAY-2 = OFF //AUDIO 2 = SCREAM
RELAY-3 = OFF //AIR VLV 1 = Prop-1
RELAY-4 = OFF //AUDIO 3 = LOUD MOAN
RELAY-5 = OFF //LIGHTS 1 = MINI LIGHTS
RELAY-6 = OFF //AIR VLV 2 = Prop-2
RELAY-7 = OFF //
RELAY-8 = OFF //

START
// is someone setting off the trap?
CHECK THE STATUS OF THE BEAM SENSOR

// spring the trap when a person walks by and start the effects
IF SENSOR-1 = ON THEN // beam sensor has activated

// Event 1
RELAY-1 = OFF // turn off background audio immediately
RELAY-2 = ON // want immediate Audio-2, it will auto off on it's own timer
RELAY-3 = ON // prop-1 activates
delay(5000) // keep prop-1 active for 5 seconds

// Pause and reset
RELAY-2 = OFF // turn it off for next go-round
RELAY-3 = OFF // deactivate prop-1 for next go-round
delay(2000) // spacer, pause for 2 seconds

// Event 2
RELAY-4 = ON // want Audio-3 to play, it will auto off on it's own timer
RELAY-5 = ON // set off lights-1
delay(5000) // keep Lights-1 active for 5 seconds

// Pause and reset
RELAY-4 = OFF // turn it off for next go-round
RELAY-5 = OFF // deactivate Lights for next go-round
delay(2000) // spacer, pause for 2 seconds

// Event 3
RELAY-4 = ON // want Audio-3 to play again, it will auto off on it's own timer
RELAY-6 = ON // prop-2 activates
delay(5000) // keep prop-2 active for 5 seconds

// Pause and reset
RELAY-4 = OFF // turn it off for next go-round
RELAY-6 = OFF // deactivate prop-2 for next go-round
delay(2000) // spacer, pause for 2 seconds

// Pause for effect, don't allow system to activate too fast after last run
delay(30000) // spacer, pause for 30 seconds

// what happens if no one walks by the sensor
IF SENSOR-1 = OFF THEN // beam sensor has not been tripped

// No Events keep background sounds running till SENSOR-1 is tripped
RELAY-1 = ON //AUDIO 1 = AMBIENT SOUND

RETURN TO START

Hi,

You definitely have the idea down pretty well.. I would start with a program template and make names that mean something for all your relay actions.

In case you haven't read over: http://arduino-info.wikispaces.com/ArduinoPower. The example program sketch near the bottom might be a good place to start as it handles the fact that this relay board has "Active Low" inputs.

So it might look something like this (Not actually what you want to do!):

/* YourDuino Example: Relay Control 1.10
  Handles "Relay is active-low" to assure
  no relay activation from reset until
  application is ready.
   terry@yourduino.com */

/*-----( Import needed libraries )-----*/
/*-----( Declare Constants )-----*/
#define RELAY_ON 0
#define RELAY_OFF 1
/*-----( Declare objects )-----*/
/*-----( Declare Variables )-----*/
#define Ambient_Sound  2  // Arduino Digital I/O pin number
#define Scream  3
#define Prop1  4
#define Loud_Moan  5

void setup()   /****** SETUP: RUNS ONCE ******/
{
//-------( Initialize Pins so relays are inactive at reset)----
  digitalWrite(Ambient_Sound, RELAY_OFF);
  digitalWrite(Scream, RELAY_OFF);
  digitalWrite(Prop1, RELAY_OFF);
  digitalWrite(Loud_Moan, RELAY_OFF);  
  
//---( THEN set pins as outputs )----  
  pinMode(Ambient_Sound, OUTPUT);   
  pinMode(Scream, OUTPUT);  
  pinMode(Prop1, OUTPUT);  
  pinMode(Loud_Moan, OUTPUT);    
  delay(4000); //Check that all relays are inactive at Reset

}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
//---( Turn all 4 relays ON in sequence)---
  digitalWrite(Ambient_Sound, RELAY_ON);// set the Relay ON
  delay(1000);              // wait for a second
  digitalWrite(Scream, RELAY_ON);// set the Relay ON
  delay(1000);              // wait for a second  
  digitalWrite(Prop1, RELAY_ON);// set the Relay ON
  delay(1000);              // wait for a second
  digitalWrite(Loud_Moan, RELAY_ON);// set the Relay ON
  delay(4000);              // wait see all relays ON
  
//---( Turn all 4 relays OFF in sequence)---  
  digitalWrite(Ambient_Sound, RELAY_OFF);// set the Relay OFF
  delay(1000);              // wait for a second
  digitalWrite(Scream, RELAY_OFF);// set the Relay OFF
  delay(1000);              // wait for a second  
  digitalWrite(Prop1, RELAY_OFF);// set the Relay OFF
  delay(1000);              // wait for a second
  digitalWrite(Loud_Moan, RELAY_OFF);// set the Relay OFF
  delay(4000);              // wait see all relays OFF  
  

}//--(end main loop )---



//*********( THE END )***********

remember you have to figure out how/when to turn the relays OFF... :slight_smile:

Let us know how you're doing...

You probably want something like this:

/*
2011
Control of a Halloween Graveyard through a 8-Relay card.
-----
-----
Arduino Duemilanove for controller
-----
Relay card here:    http://arduino-direct.com/sunshop/index.php?l=product_detail&p=156
-----
SENSOR-1
An IR Barrier Switch is the sensor. When activated it provides 9VDC to a buzzer.
	I have removed the buzzer and installed a LM7805CT to bring the 9VDC down 
	to 5VDC to act as an input the Arduino can handle.
-----
AUDIO-1,2,3,4
Sound card has 4 push buttons for 4 sounds so a CLOSED relay would = on
-----
AIR VLV-1,2
Two 24VAC solonoid valves will activate two pneumatic props, so a CLOSED 
	relay would allow a power on condition and air to flow.
-----
LIGHTS-1
An electric prop, 9VDC series of lights, needs an on, so a CLOSED relay would = on
*/

// Relay outputs are "active LOW"
const int RELAY_ON = LOW;
const int RELAY_OFF = HIGH;

// Define Arduino pin numbers for the relays
const int AMBIENT_SOUND = 2;  // Audio 1
const int SCREAM = 3; // Audio 2
const int PROP1 = 4;  // Prop 1
const int LOUD_MOAN = 5; // Audio 3
const int MINI_LIGHTS = 6;  // Mini lights
const int PROP2 = 7;  // Air valve for Prop 2

// Define Arduino pin for the trigger input
const int TRIPWIRE = 8;

void setup()
    {
    pinMode(AMBIENT_SOUND, OUTPUT);
    pinMode(SCREAM, OUTPUT);
    pinMode(PROP1, OUTPUT);
    pinMode(LOUD_MOAN, OUTPUT);
    pinMode(MINI_LIGHTS, OUTPUT);
    pinMode(PROP2, OUTPUT);

    // turn everything off but the background noises
    digitalWrite(AMBIENT_SOUND, RELAY_ON);
    digitalWrite(SCREAM, RELAY_OFF);
    digitalWrite(PROP1, RELAY_OFF);
    digitalWrite(LOUD_MOAN, RELAY_OFF);
    digitalWrite(MINI_LIGHTS, RELAY_OFF);
    digitalWrite(PROP2, RELAY_OFF);

    pinMode(TRIPWIRE, INPUT)
   }

void loop()
    {
    // is someone setting off the trap?
    if (digitalRead(TRIPWIRE))
        {
        digitalWrite(AMBIENT, RELAY_OFF);
        digitalWrite(SCREAM, RELAY_ON);
        digitalWrite(PROP1, RELAY_ON);

	delay(5000)	// keep prop-1 active for 5 seconds

        digitalWrite(SCREAM, RELAY_OFF); // turn it off for next go-round
        digitalWrite(PROP1, RELAY_OFF);  // turn it off for next go-round

	delay(2000)	// spacer, pause for 2 seconds

        digitalWrite(LOUD_MOAN, RELAY_ON);
        digitalWrite(MINI_LIGHTS, RELAY_ON);

	delay(5000)	// keep Lights active for 5 seconds

        digitalWrite(LOUD_MOAN, RELAY_OFF);
        digitalWrite(MINI_LIGHTS, RELAY_OFF);

	delay(2000)	// spacer, pause for 2 seconds

        digitalWrite(LOUD_MOAN, RELAY_ON);
        digitalWrite(PROP2, RELAY_ON);

	delay(5000)	// keep prop-2 active for 5 seconds

        digitalWrite(LOUD_MOAN, RELAY_OFF);
        digitalWrite(PROP2, RELAY_OFF);
	delay(2000)	// spacer, pause for 2 seconds

	// Pause for effect, don't allow system to activate too fast after last run
	delay(30000)	// spacer, pause for 30 seconds
        }
    else
        {
         digitalWrite(AMBIENT, RELAY_ON);
        }
    }

Hello there Mr. terryking228
Genoa, Italy (Home:Topsham, Vermont USA)

And a "big" thank you for your reply to my frantic confusion.
I have read over the www site: http://arduino-info.wikispaces.com/ArduinoPower you pointed out.
It is the same place where I purchased my relay card, YourDuino, they have a LOT of cool stuff! (I'll be going back once I get this figured out!)

As I said, I have read this site, and several others over, but I'm not figuring out how to integrate the commands. I can make the "button" command, from the examples, work. And I can flash the LED, from the examples. I have the delay figured out. My IF/ELSE statements don't work. I was hoping to modularize by using those 3 examples (BUTTON, RELAY example from the www, and IF/ELSE) and be able to just put it together. Woops.

So your example code is "greatly" appreciated. I will pick it apart and see if I can get things running now that I have logical example to follow.

Thank you.

Hello there Mr. johnwasser
Massachusetts, USA

I want to thank you for answering my call for help. As I've stated I am not a programmer. I have tried, as stated in my post above to Mr. terryking228, to modularize my program by using example codes and put them together. I should have started months earlier so I would not be rushed and would be able to understand it as I worked but things happen. So thank you, once again, very much for writing up a program that I can use as an example and tester. You've made my life a lot less hetic! And I hope the neighborhood kids enjoy the scare! ]:slight_smile:

All the best.

Well, here it is. And it is not working the way I want it.
The program should, in order:
1 - turn off all the relays
2 - turn on relay 1 to start background sounds then turn it off
3 - look for PIN8 to go active to start the events
4 - or just wait and let the background sounds run.

What it does is keep running (loop) through the Sequence Of Events, setting everything off.
Any thoughts on what I've done wrong?
Thanks.

test-3.txt (12.4 KB)

What kind of device is connected to Beam_Sensor? Does that device output LOW until triggered, then output HIGH?

The program should, in order:
1 - turn off all the relays

That's done in setup.

2 - turn on relay 1 to start background sounds then turn it off

Turned on in setup. When do you want it turned off?

3 - look for PIN8 to go active to start the events

Done in loop.

Did you write a test sketch to test the sensor? Do you KNOW that HIGH means triggered?

On my 'reply #5' I included an attached text file, as I don't know how to make the little window with the sketch in it, if you want to see my code with notes.

The beam-sensor activates a buzzer, which I removed and now I get 9VDC. I have used a LM7805 to bring this down to 5VDC which activates a NO relay. The relay is my SPST switch to Arduino pin-8 for input. I have tested this using the sketch called button, on the tutorials, and it does work.

Here are some clips from the sketch....

// Define
const int NOT_USED = 8; // RELAY-8 = NOT USED AS YET
int Beam_Sensor = 8; // choose the input pin (for beam sensor) YOUR INPUT ON PIN 8
int Beam_Sensor_val = 0; // variable for reading the pin status VARIABLE HOLDS DATA
int ledPin = 13; // Turn on the board LED lets me know if sensor input gets to the Arduino

void setup()
{
pinMode(NOT_USED, OUTPUT); // RELAY-8 = NOT USED AS YET
pinMode(Beam_Sensor, INPUT); // declare beam sensor as input
pinMode(ledPin, OUTPUT); // declare LED as output lets me know if sensor input gets to the Arduino
}
void loop()
{
// is someone setting off the trap?
Beam_Sensor_val = digitalRead(Beam_Sensor); // read input value 5VDC==ON==HIGH OVDC==OFF==LOW
if (Beam_Sensor_val == HIGH) // if the input is HIGH (IR BEAM TRIPPED == 5VDC ON PIN-8)
{
}
else
{
// Pause for effect, don't allow system to activate too fast after last run.
// delay(6000); // spacer, pause for 60000 = 60 seconds
digitalWrite(ledPin, LOW); // turn LED OFF to let me know if the sensor input gets to the Arduino
}
}
//( THE END )**

On my 'reply #5' I included an attached text file, as I don't know how to make the little window with the sketch in it, if you want to see my code with notes.

Next time you post or reply, look at the rows of icons above. See the one with the #? Select that, and paste your code between the tags. Or paste your code, select it all, and then hit the # button.

The relay is my SPST switch to Arduino pin-8 for input. I have tested this using the sketch called button, on the tutorials, and it does work.

I think I need to see a schematic, a Fritzing picture, or a photo (in that order of preference) to see how that relay is connected to the Arduino. Do you have a pull-down resistor somewhere?

If not, you might (do) have a floating pin condition, where HIGH is generated when the relay is closed and either HIGH or LOW is read when the relay is open. Of course, such resistor would show on the schematic.

I get a message saying the code is too long so I will post it in two parts: #1

/*
2011 Project - 
Control of a Halloween Graveyard Display through an Arduino with an Eight Relay card.
---------------
---------------
Parts List:
01. Arduino Duemilanove
02. Arduino Sensor Shield v4.0 - yourduino.com - p/n AS-010200
03. 8-Relay Board, optio-isolated - yourduino.com - p/n EA040402
04. Wires for pins on shield & relay card - yourduino.com - p/n CW-044020
05. Beam Sensor - Velleman Kit MK120 - http://store.qkits.com/moreinfo.cfm/MK120
06. Magnecraft W117SIP-6; 5 VDC SPST N.O. DIP REED RELAY - http://www.allelectronics.com  - p/n CAT# RLY-541
07. LM7805CT; Standard Voltage Regulator 5 Volt  - http://www.jameco.com - Part no. 786138
  Note: the beam sensor activates a 9VDC buzzer, you will not use this.  The reed relay and voltage regulator are inexpensive so
  I used the voltage regulator to bring the 9V down to 5V, because that is what the reed relay is rated for, and used the  relay
  to act as a DRY CONTACT, aka switch thinking I could copy the DEBOUNCE sketch, for a binary input which will activate the Arduino.
08. Ghostly Footprints - http://www.halloweenforum.com/halloween-props/77243-ghostly-footprints.html
09. 2 Pneumatic solenoid valves - http://www.frightprops.com/pneumatics/solenoid-valves/3-way-solenoid-valves/3-way-valve-with-1-4-inch-orifices-open-exhaust-0927-0001.html
10. 2 Pneumatic actuators - http://www.frightprops.com
11. 300 second USB recording module - http://www.electronics123.com/  - Product # USB5M
12. Air compressor - mine is an old 26 gallon unit
---------------
Recommended software:
01. Audacity - Used to edit your sounds. - http://audacity.sourceforge.net/
    Audacity® is free, open source software for recording and editing sounds.
02. CDEX - Used to change MP3 to WAV, and back, format for your sounds. - http://cdexos.sourceforge.net/
    CDex - Open Source Digital Audio CD Extractor
---------------
Notes on my setup..................................................
AUDIO FILES-1,2,3,4
300 second USB sound card has 4 push buttons for 4 sounds so a CLOSED relay would = on
I soldered in lenghts of wire, keeping the buttons for testing, to go to the various relays for activation.
This card also has multiple programable functions like auto-repeat so I setup #1 to replay on its own.
1= AMBIENT NIGHT SOUNDS = KG-background-02.wav, I made with Audacity
2= Crypt_laugh.wav, from the www
3= CorpseMoan.wav, from the www
4= GATE OPENING/CLOSING = KG-Gate07.wav, I made with Audacity
-----
AIR VLV-1,2
Two 24VAC solonoid valves will activate two pneumatic props, so a CLOSED relay would
allow a POWER ON condition and air to flow which runs the two pneumatic actuators.
Prop-1 = zombie popper
Prop-2 = haunted gate
Prop-3 = GhoSteps, 9VDC series of lights, needs an on, so a CLOSED relay would = on
         The Ghost Steps card runs 16 steps and has some timer/programming features, like delay, which I have used so
         one must match the event timing to what you choose to program the card to do.
         
--------------- 
NOTES ON SETTING UP THE HARDWARE.............................................
Place the Arduino Sensor Shield on the Arduino Duemilanove.  
Run wires from the RELAY CARD to the SHIELD CARD as follows, WIRE COLORS ARE WHAT I USED TO KEEP THINGS STRAIGHT.
         RELAY   WIRE        SHIELD DIGITAL I/O
         GND --> BLACK   --> 0G
         IN1 --> BROWN   --> 1S
         IN2 --> YELLOW  --> 2S
         IN3 --> ORANGE  --> 3S
         IN4 --> RED     --> 4S
         IN5 --> PURPLE  --> 5S
         IN6 --> GREY    --> 6S
         IN7 --> BLUE    --> 7S
         IN8 --> GREEN   --> 8S
         VCC --> WHITE   --> 0S

SETTING UP THE RELAY..........................................Diode protected, voltage/polarity matters..........
             If you are asking why use relay when I can get power from LM7805, ANSWER = CIRCUIT ISOLATION.
  RELAY HAS 4 PINS: NUMBERS (L to R) = 1, 3, 5, 7  .... 3 = +volts, 5 = GND, 1 & 7 = NO Switch
  LM7805CT HAS 3 LEGS (L to R) = 1, 2, 3 .... 1 = INPUT VOLTAGE, 2 = GND, 3 = OUTPUT VOLTAGE
    IR BEAM SENSOR BUZZER VOLTAGE = 9VDC
    IR9V --> LM7805CT LEG-1 and IRGND --> LM7805CT LEG-2
    LM7805CT LEG-2 --> RELAY PIN-5 and LM7805CT LEG-3 --> RELAY PIN-3
      YES, LEG-2, The GND is shared between INPUT and OUTPUT

Magnecraft REED RELAY pins 1 & 7 are Normally Open.  Solder wires on these two pins, with a 10k resistor on pin 7, and run them as
you would for the BUTTON sketch.

RELAY PIN-1: IN gets controlled power from SHIELD 5V PIN.     
RELAY PIN-3: IN gets relay operational power circuit from LM7805CT LEG-3
RELAY PIN-5: OUT gets GROUND for relay operational power circuit from LM7805CT LEG-2
RELAY PIN-7: OUT sends 5VDC to 10K RESISTOR and SHIELD PIN-8 (ON INPUT SIDE OF RESISTOR) then to SHIELD GND (on output side of resistor)

*/

I get a message saying the code is too long so I will post it in two parts: #2

//======================================= START __ SETUP ==========================================
// Relay outputs are "active LOW"
const int RELAY_ON = LOW;
const int RELAY_OFF = HIGH;

// Define numbers for the relays
const int AMBIENT_SOUND = 1;   // RELAY-1 = Audio 1 = AMBIENT NIGHT SOUNDS = KG-background-02.wav
const int Crypt_Laugh = 2;     // RELAY-2 = Audio 2 = Crypt_Laugh.wav
const int ZOMBIE = 3;          // RELAY-3 = Air valve 1 for Prop-1 = zombie popper
const int CorpseMoan = 4;      // RELAY-4 = Audio 3 = CorpseMoan.wav
const int GATE_SOUND = 5;      // RELAY-5 = Audio 4 = GATE OPENING/CLOSING = KG-Gate07.wav
const int GhoSteps = 6;        // RELAY-6 = GhoSteps
const int GATE_MOVES = 7;      // RELAY-7 = Air valve 2 for Prop-2 = Haunted Gate
const int NOT_USED = 8;        // RELAY-8 = NOT USED AS YET
// Define ARDUINO PIN for the trigger input
//const int Beam_Sensor = 8;     // Beam Sensor acts like a SPST switch to start the Sequence Of Events
int Beam_Sensor = 8;       // choose the input pin (for beam sensor)    YOUR INPUT ON PIN 8
int Beam_Sensor_val = 0;   // variable for reading the pin status        VARIABLE HOLDS DATA
int ledPin = 13;           // Turn on the board LED to let me know if the sensor input gets to the Arduino

void setup()
    {
    pinMode(AMBIENT_SOUND, OUTPUT);  // RELAY-1 = Audio 1 AMBIENT NIGHT SOUNDS = KG-background-02.wav
    pinMode(Crypt_Laugh, OUTPUT);    // RELAY-2 = Audio 2 Crypt_Laugh
    pinMode(ZOMBIE, OUTPUT);         // RELAY-3 = Zombie Popper Prop
    pinMode(CorpseMoan, OUTPUT);     // RELAY-4 = Audio 3 moan
    pinMode(GATE_SOUND, OUTPUT);     // RELAY-5 = Audio 4 gate sounds
    pinMode(GhoSteps, OUTPUT);       // RELAY-6 = GhoSteps Prop: times; 00-10sec, pause 10-15sec, 15-26sec
    pinMode(GATE_MOVES, OUTPUT);     // RELAY-7 = Haunted Gate Prop
    pinMode(NOT_USED, OUTPUT);       // RELAY-8 = NOT USED AS YET

    // START UP turn everything off but the background sounds
    digitalWrite(AMBIENT_SOUND, RELAY_ON);  // RELAY-1 = AMBIENT NIGHT SOUNDS = KG-background-02.wav
    digitalWrite(Crypt_Laugh, RELAY_OFF);   // RELAY-2 = Audio 2 Crypt_Laugh
    digitalWrite(ZOMBIE, RELAY_OFF);        // RELAY-3 = Zombie Popper Prop
    digitalWrite(CorpseMoan, RELAY_OFF);    // RELAY-4 = Audio 3 moan
    digitalWrite(GATE_SOUND, RELAY_OFF);    // RELAY-5 = Audio 4 gate sounds
    digitalWrite(GhoSteps, RELAY_OFF);      // RELAY-6 = GhoSteps Prop: times; 00-10sec, pause 10-15sec, 15-26sec
    digitalWrite(GATE_MOVES, RELAY_OFF);    // RELAY-7 = Haunted Gate Prop
    digitalWrite(NOT_USED, RELAY_OFF);      // RELAY-8 = NOT USED AS YET
    delay(500);	// insert pause for sound switch to recognise change of state for Relay-1
    digitalWrite(AMBIENT_SOUND, RELAY_OFF); // RELAY-1 = AMBIENT NIGHT SOUNDS = KG-background-02.wav

//  pinMode(Beam_Sensor, INPUT);  //IR Beam sensor to activate sequence of events
    pinMode(Beam_Sensor, INPUT);    // declare beam sensor as input
    pinMode(ledPin, OUTPUT);  // declare LED as output to let me know if the sensor input gets to the Arduino
   }

//======================================= START __ SEQUENCE ==========================================
void loop()
    {
    // is someone setting off the trap?
    //if (digitalRead(Beam_Sensor)) // TRIPPED BEAM SENSOR
  Beam_Sensor_val = digitalRead(Beam_Sensor);  // read input value  5VDC==ON==HIGH   OVDC==OFF==LOW
  if (Beam_Sensor_val == HIGH)  // if the input is HIGH (IR BEAM TRIPPED == 5VDC ON PIN-8)
        {
        //ACT-1 ZOMBIE ATTACK AND SOUND
        // The sensor has been activated....  MOO-HA-HA laughed the evil cow  ;)
        digitalWrite(ledPin, HIGH);  // turn LED on to let me know if the sensor input gets to the Arduino
        digitalWrite(Crypt_Laugh, RELAY_ON);    // RELAY-2 give loud scream
        digitalWrite(ZOMBIE, RELAY_ON);         // RELAY-3 popup the zombie
	delay(500);	// pause for sound switch to recognise change of state for relay 2
        digitalWrite(Crypt_Laugh, RELAY_OFF); // turn RELAY-2 off for next go-round
	delay(5000);	// keep the zombie up for 5 seconds 
                        // by keeping relay on voltage is maintaned to solonoid valve which maintains air to actuator
        digitalWrite(ZOMBIE, RELAY_OFF);  // turn off air valve to reset zombie for next go-round
                        // auto air bleed will let zombie slowly drop back down by its own weight

	delay(5000);	// spacer, pause for 5 seconds allows me to figure out SOE .Sequence Of Events.

        //ACT-2 GHOST MOANS, WALKS THROUGH GRAVEYARD AND SOUND OF GATE OPENING
        digitalWrite(CorpseMoan, RELAY_ON); // RELAY-4 need loud moan to go with start of GHOST WALKING prop
        digitalWrite(GhoSteps, RELAY_ON);  // RELAY-6 ....steps 1-8 = ~ 10 seconds....
	delay(500);	// pause for sound, and ghost steps, switch to recognise change of state for relays
        digitalWrite(CorpseMoan, RELAY_OFF); // turn RELAY-4 off for next go-round
        digitalWrite(GhoSteps, RELAY_OFF);  // turn RELAY-6 off for next go-round
	delay(10000);	// spacer, pause for 10 seconds, time it takes for first 8 of 16 steps to happen
          // Ghost has by now walked to the gate, PROP will pause for 5-6 seconds automatically
        digitalWrite(GATE_SOUND, RELAY_ON); // RELAY-4 action=sound of gate opening
          // It appears that the ghost is opening gate via sound above
        delay(500);	// pause for sound card to recognise change of state
        digitalWrite(GATE_SOUND, RELAY_OFF); // RELAY-4
        
        //ACT-3 GHOST WALKS THROUGH GATE AND SOUNDS OF GATE CLOSING       
        digitalWrite(GATE_MOVES, RELAY_ON);     // RELAY-7 action=prop gate swings open slowly
	delay(6000);	// keep prop-2 active for 6 seconds
                        // spacer, pause for 6 seconds, time it takes for GHOST STEPS PAUSE to complete
        digitalWrite(GATE_MOVES, RELAY_OFF);     // RELAY-7 action=prop gate swings close slowly
                                // auto air bleed will let gate slowly close by spring action
          // Ghost now automatically takes last steps, 9-16, which is another ~10 seconds
	digitalWrite(GATE_SOUND, RELAY_ON); // RELAY-4 action=sound of gate closing as GHOST walks through
        delay(500);	// pause for sound card to recognise change of state
        digitalWrite(GATE_SOUND, RELAY_OFF); // turn RELAY-4 off for next go-round
	delay(10000);	// spacer, pause for 10 seconds, time it takes for last 8 of 16 steps to happen
          // Give ghost time to finish last 8 steps
          
	delay(5000);	// spacer, pause for 5 seconds allows me to figure out SOE .Sequence Of Events.

        digitalWrite(AMBIENT_SOUND, RELAY_ON); // RELAY-1 = AMBIENT NIGHT SOUNDS = KG-background-02.wav
        delay(500);	// pause for sound switch to recognise change of state
        digitalWrite(AMBIENT_SOUND, RELAY_OFF); // turn RELAY-1 off for next go-round
        
        }
    else
        {
	// Pause for effect, don't allow system to activate too fast after last run.
	// delay(6000);	// spacer, pause for 60000 = 60 seconds 
        digitalWrite(ledPin, LOW);  // turn LED OFF to let me know if the sensor input gets to the Arduino
        }
    }



//*********( THE END )***********



/* 
NOTE TO ME, 
Want to add a constantly dimming set of eyes while the above program runs, need to learn PWM on pin 9?
try this later when the rest of the stuff is working

int fade_eye = 0;
int ledpin = 5;
void setup ()
{
}
void loop ()
{
  for(fade_eye = 0; value <= 255; fade_eye+=5)
  {
    analogWrite(ledpin, fade_eye);
    delay(60);
  }
  for(fade_eye = 255; value >=0; fade_eye-=5)
  {
     analogWrite(ledpin, fade_eye);
     delay(60);
  }
}

*/

I don't know how to upload a picture into my reply so let's hear it for the 80's and ASCII art!

+------* *----------+ +--------------+
| | | |
| +---diode--+ | | LM7805 |
| | | | +--------------+
1 3(+) 5(-) 7 | | |
| | |
relay 9V G 5V

+-----------------------------+
| |
+---------+------------+ |
| D8 | |
| | |
| ARDUINO | +--10k---+----(RELAY P7)
| 5V G | |
+---------+---+--------+ |
| | |
| +-------------+
|
|__(RELAY P1)

The beam sensor gives 9V which is converted to 5V by the LM7805.
The 5V from the LM7805 activates a Normally Open relay (pins 3 & 5) and closes the switch.
(I did this for circuit isolation instead of taking the 5V from the LM7805)
The Arduino, using its own voltage, gets an input on pin D8.

This works, I've made the onboard LED come on/go off with the beam sensor.

And a BIG thanks to everyone helping me with this project!!

Well, I figured out what I was doing wrong. Below is the updated sketch, without the long comments, for you to review:
Problem 1 was:
Used the same number for two different things
const int NOT_USED = 8; and int Beam_Sensor = 8; I changed this int Beam_Sensor = 9;
Problem 2 was:
The val was constantly HIGH even though it was supposed to be a digital read each loop.
Beam_Sensor_val = digitalRead(Beam_Sensor);
if (Beam_Sensor_val == HIGH)
So, I added:
delay(500); // a pause to allow the electronics to change state
digitalWrite(ledPin, LOW); // and reset the value to LOW
I've run this a few times and it works great.
Thanks to all for your help and comments! :slight_smile:

//======================================= START __ SETUP ==========================================
// Relay outputs are "active LOW"
const int RELAY_ON = LOW;
const int RELAY_OFF = HIGH;

// Define numbers for the relays
const int AMBIENT_SOUND = 1;   // RELAY-1 = Audio 1 = AMBIENT NIGHT SOUNDS = KG-background-02.wav
const int Crypt_Laugh = 2;     // RELAY-2 = Audio 2 = Crypt_Laugh.wav
const int ZOMBIE = 3;          // RELAY-3 = Air valve 1 for Prop-1 = zombie popper
const int CorpseMoan = 4;      // RELAY-4 = Audio 3 = CorpseMoan.wav
const int GATE_SOUND = 5;      // RELAY-5 = Audio 4 = GATE OPENING/CLOSING = KG-Gate07.wav
const int GhoSteps = 6;        // RELAY-6 = GhoSteps
const int GATE_MOVES = 7;      // RELAY-7 = Air valve 2 for Prop-2 = Haunted Gate
const int NOT_USED = 8;        // RELAY-8 = NOT USED AS YET
// Define ARDUINO PIN for the trigger input
//const int Beam_Sensor = 8;     // Beam Sensor acts like a SPST switch to start the Sequence Of Events
int Beam_Sensor = 9;       // choose the input pin (for beam sensor)    YOUR INPUT ON PIN 9
int Beam_Sensor_val = 0;   // variable for reading the pin status        VARIABLE HOLDS DATA
int ledPin = 13;           // Turn on the board LED to let me know if the sensor input gets to the Arduino

void setup()
    {
    pinMode(AMBIENT_SOUND, OUTPUT);  // RELAY-1 = Audio 1 AMBIENT NIGHT SOUNDS = KG-background-02.wav
    pinMode(Crypt_Laugh, OUTPUT);    // RELAY-2 = Audio 2 Crypt_Laugh
    pinMode(ZOMBIE, OUTPUT);         // RELAY-3 = Zombie Popper Prop
    pinMode(CorpseMoan, OUTPUT);     // RELAY-4 = Audio 3 moan
    pinMode(GATE_SOUND, OUTPUT);     // RELAY-5 = Audio 4 gate sounds
    pinMode(GhoSteps, OUTPUT);       // RELAY-6 = GhoSteps Prop: times; 00-10sec, pause 10-15sec, 15-26sec
    pinMode(GATE_MOVES, OUTPUT);     // RELAY-7 = Haunted Gate Prop
    pinMode(NOT_USED, OUTPUT);       // RELAY-8 = NOT USED AS YET

    // START UP turn everything off but the background sounds
    digitalWrite(AMBIENT_SOUND, RELAY_ON);  // RELAY-1 = AMBIENT NIGHT SOUNDS = KG-background-02.wav
    digitalWrite(Crypt_Laugh, RELAY_OFF);   // RELAY-2 = Audio 2 Crypt_Laugh
    digitalWrite(ZOMBIE, RELAY_OFF);        // RELAY-3 = Zombie Popper Prop
    digitalWrite(CorpseMoan, RELAY_OFF);    // RELAY-4 = Audio 3 moan
    digitalWrite(GATE_SOUND, RELAY_OFF);    // RELAY-5 = Audio 4 gate sounds
    digitalWrite(GhoSteps, RELAY_OFF);      // RELAY-6 = GhoSteps Prop: times; 00-10sec, pause 10-15sec, 15-26sec
    digitalWrite(GATE_MOVES, RELAY_OFF);    // RELAY-7 = Haunted Gate Prop
    digitalWrite(NOT_USED, RELAY_OFF);      // RELAY-8 = NOT USED AS YET
    delay(500);	// insert pause for sound switch to recognise change of state for Relay-1
    digitalWrite(AMBIENT_SOUND, RELAY_OFF); // RELAY-1 = AMBIENT NIGHT SOUNDS = KG-background-02.wav

//  pinMode(Beam_Sensor, INPUT);  //IR Beam sensor to activate sequence of events
    pinMode(Beam_Sensor, INPUT);    // declare beam sensor as input
    pinMode(ledPin, OUTPUT);  // declare LED as output to let me know if the sensor input gets to the Arduino
   }

//======================================= START __ SEQUENCE ==========================================
void loop()
    {
    // is someone setting off the trap?
    //if (digitalRead(Beam_Sensor)) // TRIPPED BEAM SENSOR
  Beam_Sensor_val = digitalRead(Beam_Sensor);  // read input value  5VDC==ON==HIGH   OVDC==OFF==LOW
  if (Beam_Sensor_val == HIGH)  // if the input is HIGH (IR BEAM TRIPPED == 5VDC ON PIN-8)
        {
        //ACT-1 ZOMBIE ATTACK AND SOUND
        // The sensor has been activated....  MOO-HA-HA laughed the evil cow  ;)
        digitalWrite(ledPin, HIGH);  // turn LED on to let me know if the sensor input gets to the Arduino
        digitalWrite(Crypt_Laugh, RELAY_ON);    // RELAY-2 give loud scream
        digitalWrite(ZOMBIE, RELAY_ON);         // RELAY-3 popup the zombie
	delay(500);	// pause for sound switch to recognise change of state for relay 2
        digitalWrite(Crypt_Laugh, RELAY_OFF); // turn RELAY-2 off for next go-round
	delay(5000);	// keep the zombie up for 5 seconds 
                        // by keeping relay on voltage is maintaned to solonoid valve which maintains air to actuator
        digitalWrite(ZOMBIE, RELAY_OFF);  // turn off air valve to reset zombie for next go-round
                        // auto air bleed will let zombie slowly drop back down by its own weight

	delay(5000);	// spacer, pause for 5 seconds allows me to figure out SOE .Sequence Of Events.

        //ACT-2 GHOST MOANS, WALKS THROUGH GRAVEYARD AND SOUND OF GATE OPENING
        digitalWrite(CorpseMoan, RELAY_ON); // RELAY-4 need loud moan to go with start of GHOST WALKING prop
        digitalWrite(GhoSteps, RELAY_ON);  // RELAY-6 ....steps 1-8 = ~ 10 seconds....
	delay(500);	// pause for sound, and ghost steps, switch to recognise change of state for relays
        digitalWrite(CorpseMoan, RELAY_OFF); // turn RELAY-4 off for next go-round
        digitalWrite(GhoSteps, RELAY_OFF);  // turn RELAY-6 off for next go-round
	delay(10000);	// spacer, pause for 10 seconds, time it takes for first 8 of 16 steps to happen
          // Ghost has by now walked to the gate, PROP will pause for 5-6 seconds automatically
        digitalWrite(GATE_SOUND, RELAY_ON); // RELAY-4 action=sound of gate opening
          // It appears that the ghost is opening gate via sound above
        delay(500);	// pause for sound card to recognise change of state
        digitalWrite(GATE_SOUND, RELAY_OFF); // RELAY-4
        
        //ACT-3 GHOST WALKS THROUGH GATE AND SOUNDS OF GATE CLOSING       
        digitalWrite(GATE_MOVES, RELAY_ON);     // RELAY-7 action=prop gate swings open slowly
	delay(6000);	// keep prop-2 active for 6 seconds
                        // spacer, pause for 6 seconds, time it takes for GHOST STEPS PAUSE to complete
        digitalWrite(GATE_MOVES, RELAY_OFF);     // RELAY-7 action=prop gate swings close slowly
                                // auto air bleed will let gate slowly close by spring action
          // Ghost now automatically takes last steps, 9-16, which is another ~10 seconds
	digitalWrite(GATE_SOUND, RELAY_ON); // RELAY-4 action=sound of gate closing as GHOST walks through
        delay(500);	// pause for sound card to recognise change of state
        digitalWrite(GATE_SOUND, RELAY_OFF); // turn RELAY-4 off for next go-round
	delay(10000);	// spacer, pause for 10 seconds, time it takes for last 8 of 16 steps to happen
          // Give ghost time to finish last 8 steps
          
	delay(5000);	// spacer, pause for 5 seconds allows me to figure out SOE .Sequence Of Events.

        digitalWrite(AMBIENT_SOUND, RELAY_ON); // RELAY-1 = AMBIENT NIGHT SOUNDS = KG-background-02.wav
        delay(500);	// pause for sound switch to recognise change of state
        digitalWrite(AMBIENT_SOUND, RELAY_OFF); // turn RELAY-1 off for next go-round
        
        Beam_Sensor_val = LOW;
        }
    else
        {
	// Pause for effect, don't allow system to activate too fast after last run.
	delay(500);	// spacer, pause for 60000 = 60 seconds when done for real
        digitalWrite(ledPin, LOW);  // turn LED OFF to let me know if the sensor input gets to the Arduino
        }
    }

//*********( THE END )***********
[code]

[/code]

Hey! Looks good...

You have the #1 technical tool: Persistence.

Wish I had a couple of these cool OrangeThingies... now that I am in a country where I won't get jailed and lashed for doing Halloween stuff.

Well, it is still a work in progress but here is a sneak peek at what is going on:

Thanks to all and Happy Halloween.

PS you can follow more details on my setup here:

Greetings all.
Now that I have all of my Christmas lights up and running (in sync to music with my own radio station) I've had time to post more videos, from Halloween, on my YOUTUBE site should you want to see the system in action.
Merry CHRISTmas to all.