To control a small demo track or for testing locs, I created a PWM controller based on an Arduino, a 4×20 LCD and a L298N power driver plus some switches, two analog linear 10k potentiometers and some other small stuff.
The L298N can control two tracks (named A and B), but I needed also some extra code to have options for the PWM behaviour, an emergency switch, settings and a sync between track A and B. With sync, Track B is controlled by the control of track A so we can move from Track A to B and v.v. without speed changes or shortcuts.
The code is created rather quick and dirty, but it works for me… I also made some errors in the connections that I solved in the code, so you might want to take a closer look at it, before using. The code contains the connections, I did not make a separate schematic. The code can be downloaded from here.