light display hardware

Hi all,

I'm just starting one of my first projects and was wondering if you could give me some pointers in terms of what I will need to buy.

I want to set up a light display with each light been turned on and off separately. Starting out with just a couple but with the possibility of having around 100.

Can anyone suggest what hardware I will need to set this up.

I'm coming from a programming background, so this is a little new for me.

If this should be in a different forum section please just point me in the right direction.

thanks
d

The below shows how to build a light control box controlled via a parallel port. You could do the same control with the Arduino.

http://computerchristmas.com/christmas/link-how_to/HowToId-4/How_To_Build_A_Parallel_Port_Controller_Box

wondering if you could give me some pointers in terms of what I will need to buy.

Yes, but not yet :slight_smile:

First, you need to let us know what sort of "light" you're trying to control: it makes a huge difference whether you're using, say, LEDs, flashlight bulbs, household AC lights, or an array of searchlights to call Batman.

Thanks Ran,

yes I was thinking it might be easiest to start off with LED's and then work up to household AC lights (which is the end idea).

LED's will be easier because they have less power requirements? Thats my thought anyway.

The end goal is to have lights/bulbs which look like your classic light bulb. Potentially up around 200 of them.

I realise I've probably set myself a bit of task starting out, but I figure I'll just work my way up to it. With a little help :slight_smile:

First, practice playing with LEDs using the Arduino's digital pins (remember, you can use the analog pins with digitalWrite(), too); once you are comfortable with that, you can move on.

The next step would be to simulate a shift register using the Arduino's pins (the "why" will become apparent soon); put your logic for this simulation into a function; into this function you will pass an array (well, a pointer), of boolean values, and another argument indicating the length of the array.

Now - in that function, you're going to want to loop thru the array, and for the first N elements (let's say "8"), you set the digital pins (you might want to use a switch case here, or perhaps a second pin mapping array to do the element number to pin number conversion). Read the element, and if the value is FALSE, write a LOW to the pin, and if it is TRUE, write a HIGH to the pin. Advance to the next pin, repeat until you run out of pins.

Before you call the function, you set up the array to have the pattern of the lights you want to display; so you might want to write a bit of code in the loop() function to randomly set the pattern of bits in the array, then call your function, and repeat.

Now, why would I tell you to simulate a shift register? Basically, because it will give you a feel of how a real shift-register works, without you needing to understand hooking up such a device, keeping everything simple until you are ready to advance. By putting the code into a separate function, you can later swap the "black-box" innards out to new code to drive the shift register, without needing to change your main code (so, you could potentially develop everything you need on the Arduino in a fell swoop, then change a few variables for the larger number of lights, swap in the hardware and various code to work with the real shift register, and if anything is wrong that looks like a code issue, you can be fairly confident that it isn't in the main code, but instead in the custom function, cutting debugging time).

Once you have the "fakey" shift register working with the Arduino's pins, I would then try to move to hooking up a few real lights. Assuming you know what you are doing with household AC, go out and get the parts for the lights (sockets, wire, lugs, crimpers, electrical tape, etc), but only a few (maybe 2 or 3, depending on your budget). You are also going to want to purchase the same number of what are known as SSRs (solid state relays); these aren't cheap (cheaper if you go surplus, though), so be aware of that. But they will do the job you want to do, which is easily switch AC currents using TTL (transistor-transistor logic - 0/5VDC, generally) levels. The SSRs you buy should have an input for TTL level switching, and an output side to switch 110VAC; when you buy them, you will notice that they have a metal base, and holes for bolts - you are going to want to attach that base to a piece of metal, with heat-sink grease in between the mating surfaces; they can get warm during operation, and need a heatsink to continue operating properly. There will be screw lugs on both the input and output sides, one pair each (TTL signal and GND on the input side, and the two poles of the AC switch on the output side). Wire the output up like you would a switch for a lamp. Wire the input with the GND to the Arduino's GND, and the TTL signal to one of the digital pins.

After checking, double checking, and triple checking your wiring (you did check, right? CHECK IT AGAIN!), you should now be able to run your code, and for those few lamps connected, they should light up like the LEDs do, and turn off as well, just like the LEDs did before.

The next step would be to get a shift register (well, several, depending on how many lights you are hooking up, read the datasheets, but most are either 8 or 16 bits wide, for 8-16 lamps), and hook that up; basically, such a register works by a few lines (a DATA line, a CLOCK line, a LATCH line, and a GND line, along with a VDD line to power it), the data line, clock line, and latch lines are connected to digital pins on the Arduino - the GND connected to GND on the Arduino.

To send data to the register, you clock it in: bring the data line high or low (depending on if you want a 1 or 0, light on or off, respectively), then toggle the clock line (take it high then low - though some are inverted, see the datasheet); when all the bits are sent, toggle the LATCH line, which writes the data over to the parallel pins on the shift register - these pins are then connected to your LEDs or SSRs, whichever. Something to keep in mind about the toggling of lines and such is the timing; if the code runs too fast, the toggling may happen at the wrong time for the shift register to keep up, and you may not get what you expect; on the datasheet, there will be what is called a "timing diagram", showing simulated traces of high-low values for each line being toggled over time, with the number of fractional seconds needed to wait, etc in between so that your timing is correct.

How do you attach more lights if you only have a certain size shift register? Well if the register is designed for it (most all are), there will be an "overflow" or "data out" or "shift out" line - this is simply daisy chained into another shift register (there may also be a clock out line, or you just hook the clock to the "master" clock line you are running with the Arduino); when the data goes beyond the "length" of the register, it will feed over into the next one (basically, shift registers are nothing more than a bunch of flip-flops daisy-chained together).

I hope this helps you; I appologize for the length, but a lot of people ask how to do this, and I want to help set them on a good path toward implementing their project, while avoiding some dead ends.

Good luck!

:slight_smile:

LED's will be easier because they have less power requirements?

There's that, plus the fact that they don't kill you if you make a mistake while learning how to wire them up :wink:

I see that cr0sh has already posted much of what I would suggest. Although I wouldn't have included the "simulate a shift register" part, unless part of your interest is in learning how they're made, rather than learning just enough about them to use them for your purposes. You don't need more than a very vague understanding of what's under the hood to hook them up and use them to blink LEDs.

If you're eventually going to be controlling 200 AC lights, though, one thing you must learn (unless you're secretly Bill Gates' nephew) is how to shop for cheap parts. As cr0sh noted, SSRs are expensive, and you're going to be using a bunch of 'em. A couple of my favorite surplus dealers have them cheap at the moment: BG Micro and All Electronics. Oops: I went to look up the URL, and discovered that BG Micro sold out of those SSRs. But they're still a good place to shop for electronic parts. Especially chips. All Electronics tends to be short on chips, but have more in the way of electromechanical parts than BG. A couple of my other favorites are Alltronics and Goldmine.

Most of the SSRs you'll encounter will have an LED for the "logic" input. So, my suggestion is to make yourself an LED version first, and see whether it does what you want. You can re-use the expensive parts of the prototype (the shift registers) in the final version. You can even re-use a lot of the prototyping work, if you make it modular: put the shift registers on one or more boards with header pins, and use jumpers to connect those boards to the LEDs. Later, you can put the SSRs on boards with the same pinout, and connect them to the shift registers with the same jumpers.

So, what should you buy? Some people misuse 74HC595s to drive LEDs, but that exceeds their specs, and you run the risk of smoking them. The TPIC6C595 is in the same general price range (you can buy them for about 75 cents apiece if you buy 25 of them from Mouser, which is about what you'll pay for 74HC595s from hobbyist outlets), and is actually designed to drive loads like LEDs.

Since All Electronics has cheap SSRs, I recommend you buy 8 from them so you can prototype one segment of AC lights to see whether that's going to work the way you want, and grab a couple hundred LEDs and current limiting resistors from them. You'll also need some perfboard suitable for mounting the chips and LEDs, and header pins and jumpers for doing the interconnections. Surplus stores often have cable assemblies from discontinued products that you can adapt to your needs, usually for much less than what it would cost you to buy the connectors and wire.

And don't forget the decoupling capacitors: switching lots of LEDs will generate lots of power supply noise, so you'll want to have more than the usual .1uF/chip bypass. You should have several microfarads of electrolytic on each segment.

Thanks for all your help!

So I'm going witht he LED's to start with. Certainly appriciate I need to learn a fair bit before I start with anything bigger.

I'm based in Australia so I've ordered from a store here littlebirdelectronics.com which seems to have everything.

This is what I got:

16x Resistor 330 Ohm 1/6th Watt PTH
1x Capacitor Ceramic 0.1uF/50V
1x Electrolytic Decoupling Capacitors - 10uF/25V
2x 8-Bit Parallel-In/Serial-Out Shift Register - 74HC165N
8x Basic LED - Yellow
8x Basic LED - Green
1x 350-Piece Wire Kit without Case
2x Breadboard Clear Self-Adhesive
1x Arduino MEGA with Atmega1280

Will the 74HC165N run the risk of getting smoked like you mentioned?

I'll let you know how I got with the first setup, seems fairly straight forward, famous last words :slight_smile:

Actually, you want shift-registers that go the other way, Serial-In/Parallel-Out, if you want to light the lights.

The shift registers you purchased I would still keep - maybe someday you want to be able to get input from a huge (ok, 16) number of switched contacts? You would hook these up to the shift registers you bought (8 switches to each register), then hook the serial line up to an input (and the clock line to an output) on the Arduino, and clock the value of all the switches into the Arduino, effectively reading 16 switches with one pin.

:slight_smile:

So I finally got this working. Had a baby girl in the meantime, hence the delay :slight_smile:

Managed to get the right shift registers going and after quite bit of bug fixing I've got 4 shift registers working. I'm going to switch over to using consistant colours for the wiring, as at the moment its all over the place.


I'm now in the process of hooking 32 shift registers up.

My one question now is (with this type of setup) if I want to switch to using some low voltage bulbs say 12V. can I simply hook the voltage and ground up to a 12V battery rather than than the arduino board?

So all I would do is change teh LED's to bulbs and the power to a 12V battery. Can I still run it off the bread boards etc?

thanks for everyone's help!

can I simply hook the voltage and ground up to a 12V battery rather than than the arduino board?

It would help if you posted a schematic, I can't tell what those driver chips are. You need to check if they can handle 12V. Also the current will be very much greater so you need to check both the current and the power dissipation of those driver chips.

Congratulations on the baby girl. :slight_smile:

Thanks!

The shift registers are 74HC595's. I had a check and this seems to be their datasheet:

So if I'm reading this right they only take 5V?

If thats so, what would you suggest is the best way to progress?