Crossing Flasher update

Electronics, Trains

A while ago received an gift certificate, it wasn’t a lot but it turns out you can get a lot of inexpensive electronic components from re-sellers (the ones in particular I bought from were based in China). Part of my order came in (it takes a long time for things to ship from China evidently) which spurred me to pull out my crossing flasher project to continue some work.

The parts I received were servos, I’m going to try to only use one but I’ve got two just in case I can’t make the rigging work. Fortunately servos are pretty easy to control with an Arduino but I came to the conclusion I needed to solve for sound before I finalized pin assignments for the lights, and servos, and sensors.

I finally decided on an Adafruit arduino shield that has an SD card reader and can play simple mono wave files (it’s a bell, doesn’t need anything complex). Even better its available as a kit! ->


Since I was making an order I decided to upgrade my soldering iron to one a bit better than the cheapy radio shack one which ended up being a great purchase!


I actually got it assembled last week but didn’t get time to test it till tonight (which it worked, yay I’m not incompetent and following directions).

With this working I need to start figure out pin assignments and start prototyping the servo and sensor control before wiring it all up!

Flasher Light Circuit Version 1 Completed

Electronics, Trains


I got my light circuit completed, it’s fairly simple and doesn’t do much other than host the appropriate resistors and transistors. It get’s four lines from the Arduino: 5V, GND, and Digital Pins 12 & 13. The flasher lights are common cathode so the 5V goes straight to the lights. To control the flashing I use the transistors, when I apply power to the transistor via one of the digital pins which connects the ground on the lights. In essence the transistor is acting as a solid state relay.

After this I started working on activating the lights, I’m looking to do a couple of options for redundancy. It seems that the time things like this don’t work is when you are at a show or showing somebody so I want to start with a push button that can be used to toggle it on and off.


It’s basically just a simple normally open push button hooked up to Digital Pin 2, the only complicated bit is the debounce to prevent weird behavior. I basically took the Arduino Debounce tutorial ( for this. Next up I’m going to work on using a couple of light sensors as another way to activate them.

Current state of the code:

const int ledRight = 13;
const int ledLeft = 12;
const int btnOverride = 2;

int ledState = LOW;
long previousMillis = 0;
int flasherState = LOW;

long interval = 500;

int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin

// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers

void setup()
  pinMode(ledRight, OUTPUT);
  pinMode(ledLeft, OUTPUT);
  pinMode(btnOverride, INPUT);

void loop()
  // read the state of the switch into a local variable:
  int reading = digitalRead(btnOverride);

  // check to see if you just pressed the button 
  // (i.e. the input went from LOW to HIGH),  and you've waited 
  // long enough since the last press to ignore any noise:  

  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();

  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState) {
      buttonState = reading;

      // only toggle the LED if the new button state is HIGH
      if (buttonState == HIGH) {
        flasherState = !flasherState;

  if(flasherState ==  HIGH){
    unsigned long currentMillis = millis();

    if(currentMillis - previousMillis > interval)
      previousMillis = currentMillis;

      ledState = !ledState;
      digitalWrite(ledRight, ledState);
      digitalWrite(ledLeft, !ledState);
      digitalWrite(ledRight, LOW);
      digitalWrite(ledLeft, LOW);

  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:
  lastButtonState = reading;

Quick Crossing Flasher Update

Electronics, Trains

I took a little time this evening to revive a project I’d started quite a while ago but hadn’t gotten much attention for quite a while. Some time ago I decided to create a crossing controller powered by an Arduino. I had gotten as far as a working prototype of the flasher on a breadboard. Tonight I decided to try transferring that two some simple PC board to keep it tidy. I found some small square boards pre-drilled at radio shack that I decided to give a whirl along with some connectors. The idea being that this component could be easily disconnected from the Arduino and lights as needed. Generally I wanted to be able to remove the gates from the module for transportation.

WP_20140130_19_55_12_Pro - Copy

On the bottom are all the inputs as I’ve labeled them, I’ve started putting the components on for light #2. The blue resistors are what came with the lights, the brown one is for the transistor, and the transistor itself controls the lights being on or off.

For L2 I need to connect the input to the resistor where I’ve marked and ground to the transistor where I’ve marked GND. I need to repeat the arrangement for L1 and run a connection to the 5V output.

Crossing Gates: Lights Flashing

Electronics, Trains

I recently picked up an Arduino  along with a copy of Getting Started in Electonics by Forrest M. Mims III with the intention of using it to build my own animation controller for my crossing gates.

I actually got the MAKE Getting Started with Arduino Kit

MAKE Getting Started With Arduino Kit

Which opened up contained these goodies:

Arduino Kit Parts

After some reading and playing around I managed to get the light flasher portion created. I still have to design the logic around activating them and actuating a tortoise which will be used for the moving the arms up and down. In the mean time I have a picture of preliminary flasher circuit on the breadboard as well as a very short video showing them flashing.

And the video:

CR23 Updates


I’ve been terrible at blogging lately but have actually made some progress on the layout. I’ve got much of the wiring done, I have all the loconet wiring done except one UP5 (I’ve got one, the standard calls for one on each side). That leaves just the track power which is basically just finding the right cinch plugs.

I’ve also made some changes in the scenery, I wasn’t happy with the way the Walthers road stuff worked out. The section that cross the track was a bit wider than the rest of the road kits so it didn’t look right and it would have been very difficult to fix, I wasn’t too happy with my paint job, and I decided I didn’t want a perpindicular crossing so I opted for an angled crossing.