Adding more than one l298 to arduino

Howdy!
I am a complete noob here and trying to get a model railroad going. I have started with Kushagra Keshari's "Keyboard Controlled Model Train Interface PS/2 v2.5"

He has two turnouts. The one I am building has three. How do I incorporate a second motor driver to operate the third turnout?

He has:

Adafruit_MotorShield AFMS = Adafruit_MotorShield();

Adafruit_DCMotor *loco = AFMS.getMotor(1);
Adafruit_DCMotor *turnoutA = AFMS.getMotor(3);
Adafruit_DCMotor *turnoutB = AFMS.getMotor(4);

Do I make a :

Adafruit_MotorShield AFMS = Adafruit_MotorShield(1); (or 2?)

and do :

Adafruit_DCMotor *turnoutB = AFMS.getMotor(5); (or some other number?)

Thank you for any help!

Will

Can you actually fit 2 shields?

If you can (like if the second one can be pressed onto and stack on top of the first) how would it avoid pin conflicts, since pin x on the Arduino would now be trying to control pin x on both shields?

None of the Adafruit motor shields use L298s so why are you talking about them?

As always the more information you provide the better the help. What are you actually using? And a link to whatever you're basing it on might help. And motor(2) on the existing shield isn't used in the odd snippets of code you posted so why can't you use that?

Steve

A keyboard to control direction and acceleration of a model train. The l298's to control turnouts.
I have one shield, but I have several of the little l298n by themselves.

[Keyboard Controlled Model Railway Layout V2.5 | PS/2

Based on this project.
The switches are coil based, not servos.

I'll try again...the code in your link uses motor(1), (3) and (4) from the shield. Why can't you use motor(2) for your extra turnout?

Steve

I have a different shield it appears. Mine is the i2c 298 rev 3, and his is the 293 rev 2. His will drive 4 and mine will only do two. So I guess I need to find one of those boards. Or do something different.

More to the point his is an Adafruit shield using an Adafruit library. I don't know what yours is and how it needs to be driven.

It might be possible to do what you need with that rev3 shield and an extra L298 or two but it's way outside my experience. It may need a complete rewrite of the software.

Buying an Adafruit Motor Driver V2 would probably be a lot simpler. They're not exactly difficult to find Adafruit Motor/Stepper/Servo Shield for Arduino v2 Kit [v2.3] : ID 1438 : $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Steve