You can use 13 LEDs if you use one of the Analog pins as your control input
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
Modeling the Reading Railroad in the 1950's
Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.
Ron!
Congratulations on taking the plunge!
Don't hesitate to ask questions if you run into a roadblock.
Dave
I'm just a dude with a bad back having a lot of fun with model trains, and finally building a layout!
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.
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.
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 mass produce with an hour at the workbench, and then install in every structure that will get lights.
rrinker Oh, LEDs, I was trying to figure out what that was on the right. If you really are using anywhere near the current limit of the ULN2003's, you probbaly wany yto feed the whole thing with a 5V power supply - the regulator on the Arduino (not to mention the USB port) can;t really supply that much current. If you put a barrel connector on your shield connected to the +5 and gnd lines, it will also power the Arduino. I'd also put something like a 10uF electrolytic across the pins of it for some decoupling. Use a 5V 500ma wall wart to run the whole thing - or if you already have a higher voltage power bus on your layout, build a simple 7805 regulator circuit on your board (a small heatsink might be needed on the regulator) and power that with your power bus, connecting the 5V and ground outputs to the proper pins. --Randy
Oh, LEDs, I was trying to figure out what that was on the right. If you really are using anywhere near the current limit of the ULN2003's, you probbaly wany yto feed the whole thing with a 5V power supply - the regulator on the Arduino (not to mention the USB port) can;t really supply that much current. If you put a barrel connector on your shield connected to the +5 and gnd lines, it will also power the Arduino. I'd also put something like a 10uF electrolytic across the pins of it for some decoupling. Use a 5V 500ma wall wart to run the whole thing - or if you already have a higher voltage power bus on your layout, build a simple 7805 regulator circuit on your board (a small heatsink might be needed on the regulator) and power that with your power bus, connecting the 5V and ground outputs to the proper pins.
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. I haven’t tried to post an Arduino sketch before but I’ll figure out how to do it if you need one. Mel Modeling the early to mid 1950s SP in HO scale since 1951 My Model Railroad http://melvineperry.blogspot.com/ Bakersfield, California I'm beginning to realize that aging is not for wimps.
You should be able to copy and paste an Arduino skecth - however it will not have line feeds so it will appear as one big line until you go back and insert aa return at the end of each lines. Most of it you can get by doing a search and repalce and replace every ; with ;<cr><lf> since all code lines end with ;, and then fix up the function definitions and comments which won;t have ; in them. Otherwise the .ino files are plain text and can be opened in Notepad as well as the Arduino IDE. You can copy/paste right out of the Arduino IDE.
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.
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.
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.
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.
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.
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?