Random operating lights in structures?

Hi Ed:

I’m familiar with All Electronics but thanks for the links.

Dave

Hi Dave

I started out with experimenting with the PIC stuff and it didn’t go well. A buddy, also ex electronics and model railroader, tried the PIC way but found it to complex and lacking in available information.

There seems to be a lot of information out there for Arduino and as advertised it’s made for dummies. I bought two items off eBay, a Uno and a development kit. I bought the Uno first then after rethinking about it I went for a development kit too.

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

http://www.ebay.com/itm/Ultimate-UNO-R3-Starter-Kit-1-for-Arduino

The most common Arduino, the Uno, has 20 outputs that can be used to switch LEDs on and off (the analog lines can be used for digital). They can only drive one or two LEDs directly, but you can find simple circuit examples that drive a transistor which can then drive a dozen LEDs per line or so, so you can run a whole town on a single Arduino and have multiple lights on multiple circuits in each building.

The most basic beginner examples show you how to turn an LED on and off and make it blink. They will typicall just use one LED, often on pin 13 (because the Arduino has traditionally come with an LED already on the board, connected to pin 13, so you don;t even have to add external components). The key thing to take away from those examples to expand it to the concept of driving multiple LED circuits is the part of the code where you spcify which pin the LED is connected to. You can reference ANY pin number, so long as you hook the LED to it. Or many at the same time. In just a few minutes I had a Knight Rider thing going with 4 LEDs, and a simple change to the code made it just sweep in one direction instead of back and forth.

It’s really hard to actually damage anything by having your program incorrect, but when connecting things to the Arduino you do have to remember things like putting current limiting resistors on LEDs. Just like if you were powering them with a toggle switch instead of a miniature computer - concept as far as the LED circuit goes is exactly the same, the difference is with the Arduino, your program turns the LED on and off instead of your finger on the toggle. So the same wiring rules apply.

ANd if you start playing around and need help with your sketch (see - Arduino was made for art students originally - it’s not a ‘program’, it’s a ‘sketch’), I can help you out. I don;t need to have your exact circuit - you might have a transistor connected to the Arduino driving 10 LEDs, but the sketch is exactly the same eve

If you have a MicroCenter store near you, they have Uno clones on sale for $6, and Mega clones for $10.

http://www.microcenter.com/product/431997/Uno_R3_MainBoard

http://www.microcenter.com/product/431995/Arduino_Mega_2560

They only have 25 stores nationwide. Here are the locations…

(scroll down)

http://www.microcenter.com/site/stores/default.aspx

Steve S

Steve:

Thanks for the MicroCenter lead. I’m in Canada so that particular source is going to be expensive with the exchange rate and shipping.

I did a brief search on the Canadian Amazon site and the clones are actually available for only slightly higher amounts in Canadian $ and lots of the suppliers offer free shipping.

Dave

Randy:

Thanks for the explanation and for the offer of help. At the rate that I am getting information from you recently I’ll have to put up a plaque with your name on it in the layout room.

I looked up the article related to the video that Steve referenced and it includes the ‘sketch’ needed to run multiple LEDs although the example only has one LED per output.

Here is the article for those who might be interested. If the link doesn’t take you directly to the page, it starts on page 99:

http://mrhpub.com/2014-11-nov/land/#99

It would be amazing to have several dozen LEDs going on and off randomly with only one or two small inexpensive micro processors running the whole show. It looks entirely doable but I can just imagine the maze of wires under the layout!

Dave

Mel:

Thanks for the leads. Unfortunately that particular supplier doesn’t ship to Canada but as I told Steve, the Canadian Amazon site has tons of listings for items available in Canada.

Dave

Sorry Dave, I forgot that you a Northerner. When I placed my Buy it Now I bought from a US seller. If your not selective there’s plenty of off shore sellers, most with better pricing too.

Mel

Modeling the early to mid 1950s SP in HO scale since 1951

My Model Railroad
http://melvineperry.blogspot.com/

Bakersfield, California

No problem Mel. Appreciate your help.

Dave

Thanks Randy!

I received my Arduino startup kit and you’re correct! It is very easy to get it up and running. On the second day I had a 12 light random light driver working on the breadboard. I ordered some add-on Arduino perf-boards and used 2N3904 transistors to drive my 9½ volt incandescant house lighting. Simple, very compact, low cost (under $10 total for the random light unit) and it works grate!

I’ve got two more pr

It’s fun, and addictive, isn’t it?

If you need to control more LEDs then there are ports, your starter kit probably came with a 74HC695 shift register - there are lessons in the learning material on using them. That lets 3 lines control 8 outputs. There are other more complex chips that can do even better - the code gets more complex as well, but you can control 64 or more individual outputs with just 3 of the Arduino’s outputs.

–Randy

Actually Randy 12 ports worked out perfect. For some odd reason that’s the maximum number of rooms that I illuminated in my houses (two mansions), 10 lighted rooms and 2 porch lights the rest have either 4 or 5 lights per house.

I bought some 3.3mm diameter micro stepper motors to operate my wig wags so that’s next on my project list. I installed some micro LEDs in the swing arms quite awhile back and I was planning on using a servo on a steel wire for movement but I should be able to drive a stepper motor to swing the pendulum. The 3.3mm motor should be the about right size for HO.

Mel

Modeling the early to mid 1950s SP in HO scale since 1951

My Model Railroad &nbs

For the small ones, I just came across this. I don;t have one, so I am only going by the description, but it syas it has the Arduino bootloader in it so it programs from the Arduino IDE just like any other one. It’s super tiny, there are 4 usable pins (6 total but 2 are for USB)

http://www.ebay.com/itm/2X-PCS-Digispark-Kickstarter-Attiny85-USB-Development-Board-for-arduino-/191722373418

I did just order other items from this seller so we shall see what sort of quality they offer. But for a small structure or whatever, this teeny little boards might be useful.

Edit: Same seller has them in 5 packs at $13.75 - $2.75 each! Insane.

I’m finding all sorts of neat stuff to mess around with. I need to get working on my workbench design - I have room and an idea for an L shaped table made from a couple of solid core doors, one leg will be for my modeling stuff, the other for electronics, with a computer in the middle - I have some electronic test equipment that can be controlled/monitored from the computer plus the DCC programmers like PR3 and Lokprogrammer.

–Randy

Dave, Mel, Randy—

It has been four months since this thread ran its course and I wondered what circuitry and program you settled on for your random lighting generator.

I’m at a stage where I’ll be installing the lighting in several multi-story downtown buildings and I’m interested in jumping into the Arduino pool.

I recieved an All Electronics catalog yesterday showing relay modules that I believe would be needed for my use since I’ll probably be driving several dozen LEDs on each output.

I’m just curious about which board you used and if you would do anything different. Did you modify an existing Arduino “sketch” or did you write your own for the random effect?

Thanks, Ed

High ED, good news!

Randy convinced me to try the Arduino so I bought an Arduino Uno and it works GREAT. Because I use 12 volt bulbs in my structures I needed to make an interface on a Arduino expansion shield breadboard. I dinked around with the programming and ended up with a super slow 12 lamp random cycle, it is fabulous!!!

If you are using LEDs the Arduino will drive them direct, no other devices needed. I already had several 5 volt power supplies, that’s all you need besides the Uno.

I bought a second Arduino Uno and made a second random light unit. I may have $25 tied up in both lighting units so they are cheap to make and work better than any I’ve seen on the market!

Thanks Randy!!!

Mel

Modeling the early to mid 1950s SP in

Thanks for that update, Mel!

Like your setup, I planned on having 12 outputs. I wasn’t sure what the current was rated on the output that’s why I was thinking of the relay board but it may not be necessary.

I have been browsing the tutorials here:

https://www.arduino.cc/en/Guide/HomePage

As inexpensive as these processors are, it is worthwhile to have a dedicated one for each structure.

Thanks again, Ed

I’m glad I caught this thread the second time around, you guys have me wanting to pick this up and start playing. [I]

Thanks!

Ed you need to determine the LED load current for each output. The Arduino Uno doesn’t have much current handling ability, I don’t remember off hand how much current the Uno will sink. I wouldn’t go with relays . . . . the relay chatter would drive me crazier than I already am.

You might have to make a transistor driver board to handle the current. The Arduino has more accessories available than you can imagine. I went with a blank breadboard Shield, Arduino calls the add-on boards Shields.

You need to visit the Arduino site for more info. I bought a Arduino book for $15 off eBay that was worthless, the site is full of info.

I have two Arduino Uno controlling two structures for a total of 24 lights. I’m going to add a third to control several animated goodies.
</

ULN2003 drivers, 5 for $4 or less oon ebay - each of the 7 outputs on the ULN2003 can drive up to 500ma, about 2.5 amps total for the chip (so obvious all 7 can’t run at 500ma). At 300ma per output, that’s at least 30 LEDs at 10ma each. That should be sufficient for darn near anyone’s town - 210 LEDs, plus you can use more than one per Arduino since there are more than 7 output pins. And there is a library for accessing the ULN2003 chip already in the Arduino IDE. I’m using one to drive the relays for my Test Track Switcher - though it turns out the relays I bought are such low current I can actually drive them direct from the Arduino pins.

–Randy

This was the relay module I had in mind, Mel, but as Randy points out, there are better options.

http://www.allelectronics.com/make-a-store/item/rlm-4/4-channel-relay-module/1.html

I can’t imagine the micro-relays are all that noisy but they do place a mechanical link into the chain and I surely don’t need the 10 amps!

I’ll stick with all solid-state.

[edit::] It didn’t take long to find a neat 2A solid state relay.

http://www.ebay.com/itm/4-Channel-5V-Solid-State-Relay-2A-For-Arduino-UNO-MEGA-2560-R3-AVR-Raspberry-PI-/171923205134?hash=item28076bec0e:g:RM0AAOSwPhdVKSCd

Thanks Mel, Thanks Randy…

Ed