Trains.com

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Random operating lights in structures?

10473 views
43 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Friday, February 5, 2016 10:50 AM

 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

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Friday, February 5, 2016 1:12 PM

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   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Friday, February 5, 2016 4:54 PM

 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

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    August 2003
  • From: Collinwood, Ohio, USA
  • 16,367 posts
Posted by gmpullman on Thursday, June 2, 2016 3:39 PM

hon30critter
I'm thinking of something like an apartment building or an office building where I want lights in various rooms to turn off and on on their own in a random pattern.

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

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Thursday, June 2, 2016 4:43 PM

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 HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.

  • Member since
    August 2003
  • From: Collinwood, Ohio, USA
  • 16,367 posts
Posted by gmpullman on Thursday, June 2, 2016 5:46 PM

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

  • Member since
    January 2008
  • From: Big Blackfoot River
  • 2,788 posts
Posted by Geared Steam on Thursday, June 2, 2016 5:51 PM

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

Thanks!

"The true sign of intelligence is not knowledge but imagination."-Albert Einstein

http://gearedsteam.blogspot.com/

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Thursday, June 2, 2016 6:22 PM

gmpullman

 

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

Thanks again, Ed

 

 

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.
 
 
 
 
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Thursday, June 2, 2016 7:59 PM

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

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    August 2003
  • From: Collinwood, Ohio, USA
  • 16,367 posts
Posted by gmpullman on Thursday, June 2, 2016 8:08 PM

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

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Friday, June 3, 2016 9:40 AM

I didn’t know the Arduino ULN2033 stepper motor driver could be used to drive switched outputs, my Arduino starter kit came with a ULN2003.
 
My current demand is very low, 35ma at 9½ volts for most ports with a max of 60ma.  I went with 2N3904 200ma transistors as a voltage interface from my 9½ volt lighting power supply.  200ma will handle almost all of the goodies on my layout, for high current things I use TIP-31 & TIP-3055.
 
You wiil have look too Randy for info on the ULN2033, the Arduino programming is a bit over my head.  I got the hang of programming the Uno to do what I needed by starting out with a Sketch from the Arduino library, it was close enough to get me going then I did some Mel mods to the timing to get it to do what I wanted.  Scratch Programming isn’t my thing.
 
I got hung up trying to build up a sketch to operate a mini stepping motor as a wig-wag, after way too much time involved I put everything in a bin box on the shelf.
 
 
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Friday, June 3, 2016 12:11 PM

 The ULN2003 isn't specifically a 'stepper motor driver' - they use it as oen in a lot of the starter kits. It's really just a package of 7 Darlington transistors with snubber diodes included (but when driving a relay you really should still add your own snubber diodes and not rely on the chip). So it can be used to turn anything on and off, up to the rated current and voltage (I think it's 40V). 4 of the outputs together can form an H bridge to drive a DC motor with PWM, like a DCC decoder's output stage, or pretty much anything else you can think of. The actual ULN2003 library in the Arduino IDE is probably geared towards using it to drive a stepper motor, for lights or other simple on/off operations you wouldn;t even need a library, just connect say D5 output to one of the UNL2003's inputs and turn it on and off with basic digitalWrite commands.

 There are other options as well, all you need is a buffer chip to allow the relatively low power Arduino output pin to drive a larger load. Even a basic transistor circuit would work - examples can be found on many of the relay boards. Much of that stuff is open source hardware so the schematics are freely available, instead of the relay coil and the snubber diode you would connect your LEDs there and that's it. All that transistor is doing is acting as a higher current switch to control teh relay coil since the Arduino can't do so directly. Whether it controls a relay coil or a string of LEDs really makes no difference. There are some technicalities that could affect how this works but experimenting is aprt of the fun and worst case with the transistor driver is you either can;t turn the LEDs off or they won't come on, it wouldnt fry anything. The ULN2003 and similar chips shouldn;t have any issues with this unless you exceed the maximum current

                       --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Friday, June 3, 2016 2:04 PM

As usual Randy is right on the money with the ULN2003!  I checked into them and for $7.54 I have 10 boards on the way.
 
I tested the one I have and it’s working from an Arduino Uno perfectly.  It was labeled Stepper Motor Driver in the Startup Kit so I didn’t go there.
 
Ed that board should work fine for what you want to do.  I know they will make my dinking around much easier.
 
Thanks again Randy!
 
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
  • Member since
    August 2003
  • From: Collinwood, Ohio, USA
  • 16,367 posts
Posted by gmpullman on Sunday, June 5, 2016 2:04 PM

RR_Mel
As usual Randy is right on the money with the ULN2003!  I checked into them and for $7.54 I have 10 boards on the way.

Excellent! Just the information I was looking for...

Thanks again to you both, Mel and Randy. (and Dave for starting the whole thread!)

Regards, Ed

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Users Online

There are no community member online

Search the Community

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
Model Railroader Newsletter See all
Sign up for our FREE e-newsletter and get model railroad news in your inbox!