Figure-5 (pg 45) in the Arduino article in the December 2016 MR shows a input to the Arduino with a switch connected to 5V driving the input. I’d like to suggest that using a pull-up and connecting the switch between the input and ground is both more convenient and flexible.
While I’m not familiar with the processors used in Arduinos, it is common practice for GPIOs to have internal pull-up resistors which pull the signal high without anything driving, such as the case of an open switch or an open-collector output from an electronic device. If an internal pull-up is not available an external pull-up (typically 10k) can be connected between the input and the supply voltage of the Arduino.
One big advantage of using a pulled-up input is that the input voltage is the same as the input device. This also allows the circuit driving the input to operate at a different voltage (e.g. 20V, 3V) than the input device (i.e. arduino in this case) or no voltage (e.g. a switch or photo transistor). This avoids the possibility of damaging the input with a higher voltage than the input device.
It also avoids the need to provide a supply voltage to the signal source when there is usually a ground wire nearby and makes it easy to test the circuit at any point by simply grounding the input.
It’s never obvious whether a signal being high (e.g. 5V) or low (0V) respresents an active signal (e.g. block occupied, mainline or diverging turnout position). It’s easy for firmware to handle an active high or low signal. So there is no “right way”. The best way is the simplest, least expensive and easiest to maintain.
Figure-6 in the same article shows two ways of driving an LED. The top circuit is similar to what I describe above. The Arduino drives the output low (i.e. ground) to turn on an LED connected to a supply voltage.
While convenient, the other approach, where the LED is