# Arduino question



## Cole&Jacksdad (Jan 20, 2011)

Can I trigger an Arduino with 3 different PIR's to activate 3 different props at 3 different times, at 3 different locations? For example, the TOT walks in and triggers a PIR to activate a prop. Then walks on and triggers another PIR for another prop in a different location of my haunt, etc.
The first prop will be a 12 volt DC pnuematic lifter mech with lights and sound. The second one will be a 12 volt DC pnuematic drop panel with lights no sound. The third will be a 12 volt DC pnuematic pop up with sound and lights. How would I write the code for this? I have the code for activating a single prop just not sure how I can control all 3. Or do I need to get 3 total Arduinos? Make sense?
Thanks!


----------



## HomeyDaClown (Oct 3, 2009)

*Soitenly*

3 Arduinos?
With one Arduino you've got at least 14 digital inputs/outputs and 6 analog inputs (which can be used for digital inputs/outputs as well) or analog sensor inputs. For a total of at least 20 ins/outs.

You'll only need 3 digital inputs for 3 PIR sensors and 3 digital outputs for your devices. I would use 5 volt coil relays with contacts rated at 2 amps or more to drive the 12 volt devices. See here: http://www.arduino.cc/playground/uploads/Main/relays.pdf

For code samples (pir and relay) see here:http://arduino.cc/playground/Code/Code

You basically need to make a loop with some delay that checks all the pir input pins for activity from the pirs. In the loop have it bail out to a function for the pir that turns a corresponding digital pin on for the relay you want to fire.

I would use pins like 2,3,4 or the pir inputs and 5,6,7 for the relay outputs (pins 0, and 1 are also used for serial/usb so they will not work in this case).


----------



## Cole&Jacksdad (Jan 20, 2011)

I have this relay board that I am going to use.
http://www.futurlec.com/Opto_Relay_4.shtml
So I just hook up the soleniods to the relay board? As far as sound to 2 of the props, can I use one wave shield for both or would I need 2 wave shields?


----------



## Cole&Jacksdad (Jan 20, 2011)

I hooked up the solenoid to one of the relays. The relays click, but the solenoid does not. Do I need to have 12 volts wired up to the solenoid and to the relays as if I wired up a trigger to the solenoid?


----------



## HomeyDaClown (Oct 3, 2009)

Cole&Jacksdad said:


> I have this relay board that I am going to use.
> http://www.futurlec.com/Opto_Relay_4.shtml
> So I just hook up the soleniods to the relay board? As far as sound to 2 of the props, can I use one wave shield for both or would I need 2 wave shields?


Just tie the optoisolator inputs (which are really just plain old LEDs) to the digital outs on the Arduino for oyur relay board. I believe you can trigger multiple sounds on a single wave shield (load multiple wav files on the SD card).


----------



## HomeyDaClown (Oct 3, 2009)

Cole&Jacksdad said:


> I hooked up the solenoid to one of the relays. The relays click, but the solenoid does not. Do I need to have 12 volts wired up to the solenoid and to the relays as if I wired up a trigger to the solenoid?


Just as your relays require power to drive their coils, solenoids require power to drive their coils as well. The output (contacts) of a relay work just like a switch, you need to provide the power for the device the relay will operate.


----------



## Cole&Jacksdad (Jan 20, 2011)

I have 12 volts going to the relay board. Wouldn't the 12 volts turn off and on through relays to the solenoid as the relays were clicking off and on?


----------



## Cole&Jacksdad (Jan 20, 2011)

Ok I got it to work. I needed a 2nd 12 volt power source. Wire solenoid to relay. Wire 2nd 12 volt to relay.


----------



## HomeyDaClown (Oct 3, 2009)

Glad it worked out.

Yes, relays act as switches but they also isolate power by design. That's how they can control a bigger device with a small amount of input power.


----------



## Cole&Jacksdad (Jan 20, 2011)

On the relay it say's 10a 250v ac. I am asuming that I can also control something that is 110 ac. Is that correct?


----------



## HomeyDaClown (Oct 3, 2009)

Cole&Jacksdad said:


> On the relay it say's 10a 250v ac. I am asuming that I can also control something that is 110 ac. Is that correct?


Yes you can. those are the maximum contact ratings for the relay. Anything less than that is fine. Exceed those and the magic smoke appears (along with a few sparks).


----------



## Cole&Jacksdad (Jan 20, 2011)

HomeyDaClown said:


> Yes you can. those are the maximum contact ratings for the relay. Anything less than that is fine. Exceed those and the magic smoke appears (along with a few sparks).


I'm about due for a good fire works show. LOL
Thanks for all of your help!


----------

