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 Lighting Controller Update

1471 views
5 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Random Lighting Controller Update
Posted by RR_Mel on Wednesday, November 23, 2016 10:58 AM

I’m still learning about Arduino programming.  My first attempt at building a 12 port Random Lighting Controller worked but it can be enhanced to 14 ports easily.  By increasing the ports that also adds to the random generator making the pattern sequencing even more random.
 
When I first got into this project I didn’t know that the pins marked TX and RX (1 qnd 2) could be used for outputs.  I included them into my sketch and wiring on a new expansion shield to gain two more outputs.  That actually simplified the wiring to pin to pin.  I use incandescent bulbs in my older structures so I need a high current driver so that is built up on a UNO expansion shield using TG62394AP seven cannel driver chips.
 
For a 14 port LED driver the UNO doesn’t need an expansion board, pins 0 through 13 are the driver ports.  +5 volts and Ground are available from the UNO power pins.
 
I bought 100’ roll of flat ribbon cable off eBay (under $20) for distribution to my structures.  Arduino connectors are ready available on eBay too.
 
I used conductors 1 through 14 for the LED/lamp power, 15 for Ground and 16 for Positive.  The UNO switches Ground so having a continuous ground available at the structure I can have lights that are not on the controller (porch lighting or fireplace, etc).
 
This is the sketch of my 14 port controller:
 
=====================================
 
 #define numleds  14                                                      
byte ledpins [ ] =  { 0,1,2,3,4,5,6,7,8,9,10,11,12,13 } ;
void setup( )  {                  
    for ( int  i=1; i <= numleds;  i++ )  {     
    pinMode ( ledpins [ i ], OUTPUT) ;
    digitalWrite ( ledpins [ i ] , HIGH) ;
   }
  
}
void loop ( )  {  
                digitalWrite ( ledpins [ random ( 0, numleds+1 ) ], lightsw ( ) ) ;
                delay ( 4000 ) ;                   
}
boolean lightsw ( )  {
 
 if  ( random (0,100) > 60 ) return LOW ;
   else return HIGH ;
}
 
=====================================
 
This is my finished Random Light Controller:
 
 
  
 
The 16 pin connector below the monitor LEDs is the LED Driver Output, the 16 pin connector above the driver chips is the high current (500ma per port) bulb drivers.  For LED operation (under 20ma per port) the high current drivers are not needed.  The monitor LEDs are not needed, they just keep me feeling warm and fuzzy knowing everything is working OK.
 
Now if one of you Arduino Gurus could get me started on a 3 pin Bi Color LED (Red Yellow Green single target signal) driver sketch I’ll get started on my new project.
 
 
 
 
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
    November 2016
  • 476 posts
Posted by j. c. on Wednesday, November 23, 2016 2:50 PM
Rob Paisley has several circuits listed for both 3 lead and two lead leds.
  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Wednesday, November 23, 2016 6:06 PM

j. c.
Rob Paisley has several circuits listed for both 3 lead and two lead leds.
 

 

Thanks  for the reply J C.


Actually I’ve been using a Rob Paisley circuit for my signaling system for over 8 years, I want to upgrade to an Arduino Mega processor.  I corrected my original post to reflect the Arduino request.

 
 
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 Wednesday, November 23, 2016 6:27 PM

RR_Mel
Now if one of you Arduino Gurus could get me started on a 3 pin Bi Color LED (Red Yellow Green single target signal) driver sketch I’ll get started on my new project.

Hi, Mel

Arduino Guru I'm not! All my components are still in a drawer waiting for my project "window" to open.

I assume you have seen the article on Pg. 42 of the December MR?

Build A Signal System With Arduino Controls ?

I'm heavily invested in Signal Animators by LogicRail and for my use, they do everything I like to see in my signals. I have not found any bi-color LEDs that represent all three signal colors accurately. The BLMA 4001 signal head is very nice and gives a "true yellow" by using three SMD LEDs.

 

http://www.blmamodels.com/cgi-bin/webstore/shop.cgi?c=search.blue.htm&t=main.blue.htm&ud=AgUAAw0ADwMFBxQUEBEcHAUBAAIHBQcFCQkTEQAA&categories=01001-00025

Regards, Ed

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Wednesday, November 23, 2016 7:29 PM

gmpullman

Hi, Mel

Arduino Guru I'm not! All my components are still in a drawer waiting for my project "window" to open.

I assume you have seen the article on Pg. 42 of the December MR?

Build A Signal System With Arduino Controls ?

I'm heavily invested in Signal Animators by LogicRail and for my use, they do everything I like to see in my signals. I have not found any bi-color LEDs that represent all three signal colors accurately. The BLMA 4001 signal head is very nice and gives a "true yellow" by using three SMD LEDs.

 

Regards, Ed

 

Thanks for the reply Ed.
 
I have a good working Paisley circuit signal system using three pin bi color LEDs.  If you balance the red/green LEDs for yellow they look pretty good then rotate the LEDs so that the red hot spot isn’t visible.  I have all my signals built and installed on my layout, unless you really look very hard the yellow looks very good.
 
I’ve been trying to come up with a MEGA sketch to drive bi color LEDs but I can’t get anything to compile.  I need a shot in the arm from a Guru to point me in the right direction for one working single common anode bi color LED from a switched input.
 
The sketch download from the December MR won’t compile either.  It is a full system design to include turnouts and I don’t need that.  I’m using a simple 8 block dual direction detection system, 16 signals.
 
 
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
    November 2016
  • 476 posts
Posted by j. c. on Wednesday, November 23, 2016 9:52 PM

RR_Mel

 

 
j. c.
Rob Paisley has several circuits listed for both 3 lead and two lead leds.
 

 

 

 

 

Thanks  for the reply J C.


Actually I’ve been using a Rob Paisley circuit for my signaling system for over 8 years, I want to upgrade to an Arduino Mega processor.  I corrected my original post to reflect the Arduino request.

 
 
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.
 
 

 

no problem as for the arduino don't have the slighest notion what it is unless it is what is called a picax, IC's are my limit. 

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!