Most modelers are not comfortable doing electrical wiring much less electronics and further still, programming. But the coding for many model railroad projects isn't really the problem, it's customizing it for a particular situation.
The biggest benefit of a software solution is that it is relatively easy to modify. Even if the processor is under the layout, a long enough USB cable can often be used to access the board, make and test the modification while working next to layout instead of crawling under the layout multiple times. It also encourages just trying something new because if it doesn't work out you can just reprogram it to the original code.
Another significant software benefit is that once the code is written, it can be re-used on many processors on the layout. However, what may need to change is the configuration, for example, if multiple turnouts need to be switched when using servos. Of course, generic groups of pins can be used on each Arduino for the turnout and panel switch pins often requiring no changes.
A common problem inexperienced programmers make is to embed their needs in the logic of the program. This approach may require modifying the code in more complicated applications. But typically requires more code and a typo can easily break the code. A better approach is instead of embedding the configuration as logic, it can be captured as data in the terms a railroader would understand.
Controlling, much less configuring the software of a complicated interlocking (below) can be daunting. Of course toggle switches and LEDs can be used but is tedious for an operator, especially one without experience. A modern version of a diode matrix using software makes aligning a route simple. But programming a processor to do this is challenging.
I believe the challenge for the programmer is to be able to represent the configuration in a table of data that doesn't require programming skills to read or modify.
For example, the following table entry describes a route selected when buttons x3 and c6 are pressed. The route requires that switch s63 and crossover x61 be reversed and crossovers x59, x57 and x54 be set normal.
{ Bx3, Bc6, { &s63r, &x61r, &x59n, &x57n, &x54n }},
Each switch is described by a ID, a switch position, N/R, corresponding bit value, 1/0, and Button switches are similarly described. Switch 63 is controlled by bit 2 on chip 1 and is reversed when its bit is set to 1. The ID and text string is used for debugging.
const PROGMEM SwMach_t s63r = { 63, R, 1, { 1, 2, "s63r" }};
The table for the interlocking above has ~60 routes. It is challenging just to get the table entries correct. Can you imagine what it would be like if code was involved?
No doubt some of this is tedious, but no more tedious than wiring it up. (The initial wiring to test it and using a crude panel with buttons without LEDs)
A big help when wiring is to drive panel LEDs from the switch machine that indicate the actual state of the turnouts, and not by the processor.
The above approach using tables could be used with different types of switch machines, even a mix by adding a type (e.g. Tortoise, servo) to the table entry and using different sub-functions for MCP23017 and PCA9685 devices.
The
software to manage the interlock using a table is not trivial but once written can be used elsewhere.
Final installation and panel