My N scale model railroad has about 50 mainline ... as well as manual local and via Digital Command Control with a DCC throttle. I'm adding another 30 to 40 or more turnouts for yard tracks ...
This module implements the DCC protocol for controlling model trains using a Raspberry Pi. It is able to output direction and speed DCC-encoded packets on one of the GPIO pins (see example below).
In a sound-equipped N scale locomotive ... This digital amplifier plugs into the layout's control station and echoes your DCC sound-equipped locomotives' sound effects through up to six speakers ...