FREE USA SHIPPING ON ORDERS OVER $100 On Dr.Duino.com

Dr.Duino Explorer & Model Rail Road Lighting Effects

Over the past few months, I've been dabbling in the model railroad space. Its been a very happy and nostalgic reminder of my childhood.

But boy have things changed. The level of control you can now incorporate is just insane.

But the issue I found is that in order to light your crossing signals or add some sound or just about anything else, requires these funky stand alone modules which are roughly 4 bajillion dollars.

So instead of doing that, I broke out my trusty Dr.Duino Explorer Edition and started hacking away.

I can't give away too much info right now, but I am going to be releasing some very cool model rail add-ons in the near future so sign up below if your interested in knowing when that's available.

Simulating Hardware

Before I wired stuff up in my model rail layout itself, I needed to scratch out some concepts I had.

So I could find out what I liked/didn't like, what would work, what wouldn't etc.

One of the things I was really interested in doing was creating realistic lighting effects.

Luckily, the Dr.Duino Explorer, has a built in 16 million color capable LED stick.

Creating Realistic Flames

In the video, you'll notice that I wanted to create a flickering effect which would simulate something being on fire.

So things like a fire pit, or oven or anything else which requires a nice flicking shimmer.

I did this using a one of the 8 on board LEDs by mixing Red and Green together to create a nice orange color.

But here's the clincher, in order to make it look real, I didn't just want to set a static delay between turning on and off.

I wanted it to be more random.

So I turned to the Random function built into the Arduino IDE.

Using this in conjunction with the color mixing, it created a really nice and more importantly, realistic flame color and effect.

Now all I need to do is bury one of these LED's inside a pile of sticks to simulate a fire burning just like this one.

 

The Code

Below is the code I used to create the fire lighting effect. Feel Free to use it, you will need to install the adafruit neopixel library for it to work.

I've also posted the code here so you can just copy and paste, just take everything in red below.

/*Dr.Duino Lighting Effects Demo Code
 * for the model rail fan.
 * www.DrDuino.com
 *
 */#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel strip(8, 6, NEO_GRB + NEO_KHZ800);
int        ToggleFlashPattern   = 1;

//----Modify these values below
int       RedComponent      = 255;// Full Red
int       GreenComponent    = 20; // Just a touch of green.
int       FlickerRandomDelay = 50;// Change this number to adjust the randomness of the flickering. recommend anything less than 50

void setup()
{
  // put your setup code here, to run once:
 strip.begin(); // Initialize NeoPixel strip object (REQUIRED)
 strip.show();  // Initialize all pixels to 'off'
 
}

void loop()
{

      if(ToggleFlashPattern == 1)
      {   
           /* Notice that we are passing in the Red and green values.
           *  They are set up in the variables section.
           *  Red is set to 255 and Green set to 20.
           *  This gives a orange kinda color. Mess with these numbers
           *  till you get what you like. 0-255 is valid.
           *  We are also putting in a random number delays betwen turning
           *  on and off. This gives a more reaslistic feel to the simulated
           *  fire.
           */
          
          strip.setPixelColor(0, strip.Color(RedComponent,GreenComponent,0));
          delay(random(FlickerRandomDelay));
      }
      else
      {
        strip.setPixelColor(0, strip.Color(0,0,0));  
      }
      ToggleFlashPattern = !ToggleFlashPattern;
      strip.show(); // Show the lights
}

 

That's it!

I hope you found that useful, if you want to know more about when the model railroad edition will be rolling out, just sign up below!