One day recently while watching videos on Model Railroader Video Plus, I came across a four-part series on using Arduinos for things like layout sound effects and animated lighting. I had never heard of Arduinos before, and those are aspects of the hobby that have been on my mind because it’s something I can work on without already having a layout, and it’s something that I can spend time getting familiar with, so that I’m ready with some automation solutions when I do have the space for a layout.
As Wikipedia describes them, Arduinos are “single-board microcontrollers and microcontroller kits for building digital devices and interactive objects that can sense and control objects in the physical and digital world.” Arduino boards will enable me to create the kind of electronic circuits I’ve had in mind, without the need to create the logic out of just the right combination of resistors, capacitors, timer chips, diodes and other electronic components, most of which I have very little understanding of. When circuits like those don’t work as expected, my lack of knowledge of those things makes it very difficult to troubleshoot. Arduinos, however, use the C++ programming language and a special Arduino library, to perform all of the logic, using a series of pins and pin sockets (like on breadboards) for input and output, where the input can be things like sensors (for light, sound, motion, pressure, temperature, etc.), buttons and switches, and the output can be attached to things like digital displays, LEDs, speakers, and small motors. The hardware and software that make up Arduinos are open-source, and there’s a huge community of users who share code and ideas, including some specifically for model railroad projects. The fact that the Arduino platform uses C++ is a key part of the usefulness to me, since I’m very familiar with the syntax and structure of C++, through my work experience with languages like ActionScript, JavaScript and PHP, which are all based on C++.
My familiarity with C++ is a huge asset for a model railroader trying to use Arduinos for layout automation, but there is still a little bit of a learning process. Most of the programming work I’ve done is for web pages where all of the code on a page is executed on the server before the page is presented in the browser. When programming for an Arduino, however, most of the code exists in a loop that executes endlessly. Writing code for that takes a different way of thinking, and so I’ve spent a lot of time recently trying out different ways to accomplish seemingly simple things, like alternating crossing signal LEDs that have a slight on-and-off fade to simulate the look of incandescent lights turning off and on. One of the other great things about Arduino boards is their affordability. Arduinos made by the Arduino company only cost about $20, but since the hardware is open-source, other companies manufacture 100% compatible boards that cost even less. I bought a clone, the Elegoo Uno R3 for $10.86 on Amazon, and when I was at Vetco Electronics, I picked up a different clone for about $13. They both work the same, except the one I bought from Vetco required a special driver for my Mac that was very difficult to find, and that board lacks an LED that my other board has (Off-hand, I think it is a power-on LED that’s lacking.).
Some of the projects I intend to incorporate Arduinos into are crossing signal automation (including train detection and moving gates), background sound effects, animated cinema marquee, and possibly block signal automation. Arduinos would enable me to write my own customized version of Rob Paisley’s automated block signal system, but after recently learning more about DCC, I’m now leaning toward using a DCC solution for at least the block detection aspect.