Random switching for structure lighting

I’d like to switch about a dozen individual structure lights on and off randomley at about a minute duration to simulate people movement. Any ideas as to how to go about it?

Ron Hume.

Piece of cake Ron, Arduino Uno. You can direct drive 12 LEDs from the UNO with a random sequence. You can pick up a UNO for under $6, they run off 5 volts DC.

The Uno has a max current of 20 ma per output, if you’re not using LEDs you can make a 500 ma driver for about $6.

Edit:
This is a picture of my 12 port 500 ma driver

The 13 pin micro connector next to the ULN2003 chips is the high current output connector to my buildings. The 13 pin connector next to the LEDs is the LED output connector. The LEDs on the board are for testing the Uno, they plug in to sockets and are removable.

I haven’t tried to post an Arduino sketch befo

Or make the driver anyway, and run a bunch of LEDs off each port. a bedroom in this house, an office window in that building over there, etc. all on one channel, then say another room in the house, a store, etc on the second channel. Just not multiple ones next to each other so it’s obvious they are going on and off together.

–Randy

Ron:

I’ll second Mel’s recommendation to use Arduinos. I’m just in the process of learning how to program them, but code for your purposes can be found on the internet already written for you. Model Railroad Hobbiest has had a series of articles on the Arduinos, at least one of which addresses random lighting.

http://model-railroad-hobbyist.com/

The on-line magazine is free and you can reference back issues.

One suggestion I read about house lighting is to set lights up in adjoining rooms so that one goes off and the other comes on after a very slight pause. That mimics the effect of a person turning the lights off as they leave a room and turning the lights on as they enter the next room.

Dave

Thanks Mel,

Sadly I don’t understand foreign languages or programming. I have a 12 volt 500 ma power source and I’m just looking for an off the shelf gizmo to do the job. A timer switch with half a dozen outputs? Something like that.

Ron Hume.

Randy convinced me to go Arduino, I’m sure he can convince you too. Unless you can find a cheap used mechanical cam/micro switch assembly anything else will be in triple digits.

Going fancy with an Arduino Uno is by far the cheapest way to go. This forum is loaded with Arduino help.

You can use an Arduino Uno to drive 12 LEDs without even having to solder anything, everything plugs in. The software is a freebee and the Uno will plug into a USB port on your computer for easy programming. The Uno will run on a 5 volt wallwart, we are talking less than $15 to your door for all the components for 12 random 20 ma outputs.

Guys, jump in and convince Ron that he can do it.

Mel

Ron:

I think you would find that setting up an Arduino would be simpler than what you are picturing in your mind. If you can use a computer keyboard, which you obviously can, all you would need to do is plug a USB cable into your computer and copy some text. You don’t have to understand computer programming with its “foreign language”.

Wiring the system would be no different from what you would have to do to use a timer switch.

You will need to get a different power supply. The Arduinos operate on either 3.3 volts or 5 volts IIRC.

There are devices that will do what you want without any need for programming. Ngineering is one source that offers structure lighting animation systems. Unfortunately they will only drive three LEDs each so the cost will add up if you need to use a bunch of them. Go to the Lighting Effects Products page. If the website view is messed up try using Firefox:

http://ngineering.com/lighting%20effects%20for%20structures.htm

Your power supply will work with the Ngineering components.

Dave

There was an item in the new products section of last month’s MRH that mentioned a 6 line device from NJ International but I don’t see it on their web site. About the only sure thing is it will cost a lot more than an Arduino Uno board and a few hours poking through the standard LED blinking tutorials to see how you turn the lines on and off and set delays.

Keep in mind the drive behind the Arduino was to enable ART STUDENTS to include high tech interactive stuff in their works - there are some that are designed to be sewn into clothing, for example. It’s why what everyone else in the world calls a ‘program’, the Arduino world calls a ‘sketch’ Art students - not engineers.

–Randy

[quote user=“RR_Mel”]

Piece of cake Ron, Arduino Uno. You can direct drive 12 LEDs from the UNO with a random sequence. You can pick up a UNO for under $6, they run off 5 volts DC.

The Uno has a max current of 20 ma per output, if you’re not using LEDs you can make a 500 ma driver for about $6.

Edit:
This is a picture of my 12 port 500 ma driver

The 13 pin micro connector next to the ULN2003 chips is the high current output connector to my buildings. The 13 pin connector next to the LEDs is the LED output connector. The LEDs on the board are for testing the Uno, they plug in to sockets and are removable.

Ron

I bought an Arduino Kit to get started but that wasn’t necessary, I bought a second Arduino Uno from a USA seller on eBay for $6.89 free shipping. His price has increased to $7.25 free shipping.

http://www.ebay.com/itm/UNO-R3-ATmega328P-CH340-USB-Board-for-Compatible-Arduino-DIY-/321871945148

The Uno comes with a short USB cable ready for programming.

I bought a USB wallwart power supply like the ones to charge cell phones and tablets to power the Uno for operation.

http://www.ebay.com/itm/152014995619?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

Randy

I rarely ever drive my LEDs more than 10 ma, they probably average in the vicinity of 5 to 7 ma. The LEDs on the expansion shield are running under 3 ma. They only need to be visible for testing the Uno.

And if you are afreaid of ripoffs on eBay, there are similar priced Arduino options on Amazon, even ones with Prime shipping. I have a stack of them now, an Uno, a Megas, about a dozen Nanos, and a half dozen ATTiny85’s that I’ve installed the Arduino bootloader on so they can be programmed like any other Arduino, just less pins.

For one or two LEDs per pin, no, no additional driver circuitry would be needed. I guess I just think bog - even on our temporary 4x8 we built each year, every structure had a light in it. If instead of one central light, that same small layout and same number of buildings, but with multiple LEDs to be lights in different rooms plus exterior lights, it would have been 40 or more LEDs. Lots of outputs especially in the Old West town if I wanted to have the lights flicker like candles and oil lamps. I don’t even want to think how many I will have in my still planning basement size layout. Although I’m thinking in many cases, each structure would have its own small chip, like the Tiny85 (there are others witht he same 8 pins, same outputs, just less RAM and Flash, which should be fine for simple light on/off programs, but they aren’t always cheaper). That way there’s never be any synchronization between lights going on and off in different buildings close enough to make it obvious they are ont he same circuit. Plus each structure would just need a power supply connection, not multiple wires coming from the centralized controller to the individual LEDs. The thing is, it is super easy to crank these things out by the dozens - once you have one program that works, you edit a couple of numbers to change the cycle time, making some stay on longer and others run for shorter times, and just keep blasting the otherwise same program to each chip. A mini experimenter board (you used to get them at Radio Shack, they should be available at other places) with an 8 pin socket and pads around the outside to connect wires for the LEDs in another thing you cna

Thanks to Mel, Dave and Randy for your responses. After a litle research, I decided to, “have a go mate” and bought an Arduino clone on ebay. (Unable to buy the genuine article in Australia.) I’ve downloaded the program and wait for the delivery, hoping the program language is compatible. I believe it should be “C++” but some clones are advertising “java” as the lingo.

I copied a sketch from the web to get me started, hoping I can tweek it to meet my needs. Had a quick look at a C++ tutorial, but it’s too much of a steep learning curve at my age. Once again, thanks for the advice.

Ron Hume.

The Arduino IDE includes all the sample coide to learn from. The very first one is pretty much all you’ll need for ‘random’ lighting - it’s called Blink because it makes an LED blink. You can access all the tutorials online at the Arduino site so you can get the explanations for each line of code. The default in blink is I think every second or every half second. It will be pretty obvious how you change that. Adding more output lines to control more LEDs is a later tutorial but it’s really just a variation on the blink program.

The language used in the Arduino IDE is mostly C++ but for what you are trying to do there is no reason to attempt to learn the entire language, you will only be using a minor subset of it to write the kind of Arduino programs you need to turn LEDs on and off.

There are other ways to program Arduinos besides the Arduino IDE, but all of them are more complex than the standard IDE so those options are best left until you have some more experience. A true Arduino clone will have the Arduino bootloader already programmed and will plug in to your computer and the IDE will just work. Some of the ones I have came with the Blink sketch already loaded - as soon as I applied power, the LED started blinking. That almost requires you to adjust the delay times in the Blink sketch so you know you board successfully accepted the upload of code - if you just upload what’s already there, nothing will change and the LED will blink away, but if you change the speed of the blinking, you will see it change when you upload.

Unless you bought a starter kit that comes with a bunch of parts, you won;t be able to actually build the various demonstration circuits. Mostly you only need to work with the ones that control LEDs, because that it what you are trying to do, so if you don;t have them you might want to get some LEDs and resistors, a small breadboard, and some jumper wires so you cna play around with this while learning.

Ron!

Congratulations on taking the plunge!

Don’t hesitate to ask questions if you run into a roadblock.

Dave

Ron

This is the Arduino Uno Sketch for my 12 port Random LED driver.

#define numleds 12
byte ledpins = { 0,3,4,5,6,7,8,9,10,11,12,13 } ;
void setup( ) {
for ( int i=1; i <= numleds; i++ ) {
pinMode ( ledpins [ i ], OUTPUT) ;

You can use 13 LEDs if you use one of the Analog pins as your control input [:D]

Or use all 5 of them for control over 5 zones, each with 1 or more LEDs

Digital input on an Alalog port works. For the ultimate in crazy features - use some pots on the analog lines to adjust the delay and random factors, then you can adjust things without uploading a new program each time.

But that is quite straightforward and about the only ‘advanced’ feature is the use of the array for the pins.

–Randy

Description: This is Arduino Uno R3. In addition to all the features of the previous board, the Uno now uses an ATmega16U2 instead of the 8U2 found on the Uno (or the FTDI found on previous generations). This allows for faster transfer rates and more memory. No drivers needed for Linux or Mac (inf file for Windows is needed and included in the Arduino IDE), and the ability to have the Uno show up as a keyboard, mouse, joystick, etc.

The Uno R3 also adds SDA and SCL pins next to the AREF. In addition, there are two new pins placed near the RESET pin. One is the IOREF that allow the shields to adapt to the voltage provided from the board. The other is a not connected and is reserved for future purposes. The Uno R3 works with all existing shields but can adapt to new shields which use these additional pins.

Note: The Arduino Uno R3 requires the Arduino 1.0 (or any other recent version)drivers folder in order to install properly on some computers. We have tested and confirmed that the R3 can be programmed in older versions of the IDE. However, the first time using the R3 on a new computer, you will need to have Arduino 1.0(or any other versions) installed on that machine.

Features:

Ron!

Well sir, you certainly seem to have jumped in both feet first!

Seriously, for that level of lighting you will want to experiment with some fairly high value resistors.

I used 10,000 ohm resistors for the light over the conductor’s desk in these cabooses (middle window). They look fine in daylight but they are a bit too bright at night:

I used 30,000 ohm resistors in this McKeen Motor Car and the LEDs are still too bright at night:

This picture was taken in a pitch black room but the LEDs are still a bit too bright when viewed in a night scene with normal lighting levels:

For your purposes I would suggest trying something around 48,000 ohms and maybe higher.

Mike Lehman is an expert in LED lighting. Hopefully he will chime in.

The nice thing about getting your resistance right is that resistors are cheap.

Good luck! Please show us your results.

Dave

The Arduino can use up to 12V because there is a 5V regulator on board. If you are going to low current gas light effects witht he LEDs, you should be fine with 10-12 LEDs connected to the Arduino. The voltage on the Arduino lines will be approximately 5V when on so Dave’s resistor selection may be a little too high, since those are operating at 12V+. It’s a good starting point though.

Another example to look at is the one that dims the LED using one of the PWM outputs on the Arduino. Get the parameters right and instead of just a dim LED you get perceptable flickering - just the thing to simulator oil lamps and candles. Keep in mind that while a 10K resistor may be fine for the nicely glowing LED at a full 5V, it may be too mig for the LED to light under PWM especially when set for very low duty cycles for the dim/flickering appearance - what’s happening is that when PWM is enabled, the voltage is varying between 0 and 5V at a rate you can control with the program, and the ratio betrween the on and off times determines the average voltage the LED sees. So some experimentation is in order before you wire things to your layout for good. If you get no resistors less than 1K, you won;t be able to blow any of the LEDs up/ They might be too bright for your application but even if connected to 12V instead of 5V, 1K limits the current to well within what the LED can handle. Go up from there to get the brightness level that works for you. And remember that LEDs are polarity sensitive, so if you hook one up and your program doesn’t turn it on, check that the LED is connected the right way as well as checking for a mistake in the program.

–Randy