Relay with external power?

Bear with me because I have no idea if this is even feasible or not. Plus I know a little about electronics, but not a whole lot. My current project is wiring my bicycle with lights. I have some lights already hooked up and wired to a switch box, but the idea of automation intrigues me. You know those awesome Christmas light displays that are programmed to music? That's what I'm researching. Obviously I need something portable, so I'm looking at the Arduino Uno and it looks all fine and dandy, except for the part that says:

Each of the 14 digital pins on the Uno can be used as an input or output [. . .] They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA

This simply won't do as each light (so far) runs off of a AA battery pack that provides either 12v or 6v (depends on the light). I'm planning on getting a 12v 5Ah SLA battery to simplify things, but that's neither here nor there. So here's my hypothetical situation:

  • Connect relay to Arduino (what kind of relay would I even need?)
  • Connect external battery to relay
  • Connect lights to relay

So basically I want the Arduino to just control the on/off states on the relay and not provide any direct power to the lights themselves (since that won't work anyway with the low voltage and current). It seems simple enough, almost deceptively so. Am I missing anything crucial? Thanks in advance.

EDIT: I should clarify that I tried googling this stuff before posting here, but all the diagrams and charts and jargon is altogether too confusing for me to sift through.

majhi:
So basically I want the Arduino to just control the on/off states on the relay and not provide any direct power to the lights themselves (since that won't work anyway with the low voltage and current). It seems simple enough, almost deceptively so. Am I missing anything crucial? Thanks in advance.

You would probably use a transistor rather than a relay, but you have the basic idea. There is a whole section of the forum dedicated to discussing this type of thing.

A transistor, you say? Pardon the noob-ness, but if I need multiple channels to operate each light independently, wouldn't a transistor not work? From my understanding (which is more than likely very wrong), isn't a transistor limited to a single throughput?

EDIT: A little more research dug this up:
http://www.ebay.com/itm/8-Channel-12V-Relay-Shield-Module-Arduino-ARM-PIC-AVR-DSP-SRD-12VDC-SL-C-New-/390369130004
Is that what I'm looking for?

majhi:
A transistor, you say? Pardon the noob-ness, but if I need multiple channels to operate each light independently, wouldn't a transistor not work? From my understanding (which is more than likely very wrong), isn't a transistor limited to a single throughput?

You would need multiple transistors just as you would need multiple relays; both devices can act as a switch, the primary difference with relays is electrical isolation.

Hell most relays are driven with a transistor anyway.

Thanks for all your input guys. I think I have settled on this item as it can also provide power to the Uno itself with a 5v rail:

Seems simple enough.

A 15 pack of transistors at Radio Shack is $2.99. If you've got money to throw away, throw some my way, eh?

The next thing you'll want to do is PWM some of the lights, and the relays can't be PWMed. Transistors can.

majhi:
Thanks for all your input guys. I think I have settled on this item as it can also provide power to the Uno itself with a 5v rail:
16-Channel 12V Relay Module – SainSmart.com

Seems simple enough.

That still requires 16 pins to run and it's fairly big and heavy. There are plenty of methods to run a pile of LEDs that are a lot less complicated, cheaper etc. I would go with a i2c LED controller it's easy to get 100's of LED's off of 2 Arduino pins and generally only needs a pair of resistors for the i2c buss. The cheapest is a pack of transistors one per pin, connect between the LED's and the +5v rail.

majhi:
Thanks for all your input guys. I think I have settled on this item as it can also provide power to the Uno itself with a 5v rail:
16-Channel 12V Relay Module – SainSmart.com

Seems simple enough.

Hey, just wanted to let you know I've already experimented with the 8-relay Sainsmart 5V relay board. They work REALLY well. I'm going to be using the 4 relay version for a commercial project. Note that you need a pin for each relay. So if you're using the 16 relay board, you're going to have to use a shift register or multiplexor or two in order to access all the relays from the Arduino Uno. Also be aware that by for these relay boards HIGH = relay off, LOW = relay on.

Here's a video of mine running my test program on the Arduino:

Here's another tip... don't use pins 0 and 1 (the RX and TX) for one of the relays... When you upload a program to the Arduino you'll cause that relay to switch WAY fast. Will probably shorten the life the relay. I accidentally did this because I wasn't thinking. I gotta stop prototyping in the middle of the night!

Relays are really a waste for this. Slow, mechanical, clicky, power-hungry... Transistors do the same thing, cheaper, more reliable (no moving parts), and with less energy waste.

A simple N-channel FET would be ideal. V+ to LED+, LED- to appropriate resistor, resistor to FET drain, FET source to Gnd. Finally, FET gate to digital pin of your choice. Provided the digital pin outputs enough voltage (threshold is usually 2-4v) over the FET source voltage (Gnd), the transistor turns on, current flows through the LED. Easy as pie.

Only reason someone would choose to use relays in this case is that they're not comfortable with transistors. Expand your horizons!! :slight_smile:

Sorry for the late response, had to get through finals before I could come back to thinking about this. Okay, so I'm going to try to follow SirNickity's response and expand my horizons. Google is not providing me with much luck, so if someone could point me in the right direction, that would be much appreciated. I need to build something that will run off the Arduino's I/O ports with at least 10 separate channels. To restate OP, I'm trying to make a portable, music-synced light show.

I must admit, this feels awfully over my head...