Does the Keyes L298 support a stepper motor connection (4 pins) ?

On my motor driver board there is only 2 pins output for Motor A and 2 pins output for Motor B. My stepper motor has 4 input pins so how do I connect this to my driver board???

See attached pic for my driver (KEYES L298)

If my memory serves me, you need a 297 in front of the 298 to act as an "intermediary" bewteen the uC and the 298. At least, that's the way I did it many years ago, but I'm not sure if the 297 is a "must" under these circumstances.

Can you please elaborate what you mean by these terms 297 and 298. I'm new to the whole thing...

The L298 is a sister chip to the L298 which is the actual motor driver.

If you look at figure 8 in the L298 datasheet you’ll see how it works. You control the 297 from (say) your Arduino, giving the 297 a signal for direction and you step the motor by pulsing the clock line. The 297 does some internal magic and then provides the signals to the L298.

I don’t know if it’s feasible to control the L298 directly to drive a stepper: I suspect it’s not, but not 100% sure.

why do I need the L297 if I can control the L298 with my digital PWM pins?

Because the 298 simply expects a direction pair of signals (optionally coupled with pwm for speed), and outputs a voltage on a pair of lines to drive a DC motor. To drive a stepper, you need input to the stepper which "pulls" the motor round as it "follows" the windings so to speak. So somehow or other you need to switch the outputs from the 298 to energise the windings in the right sequence to pull the motor round.

I'm not sure it's feasible to do that in software: the 297 is made for the job. All you need to give the 297 is a pulse for each step.

On my motor driver there is only 2 pins output for Motor A and 2 pins output for Motor B. My stepper motor has 4 input pins so how do I connect this to my stepper motor??

So your question is: i have 2 pair of outputs, how do i connect them to my motor that has 4 wires ?

You can look up your motor's datasheet or use a multimeter to find out what wires belong together of that motor.
The datasheet will tell you how to wire it up.
Beeping the wires with your multimeter just tells you the pairs that belong together.
After beeping you might need to reverse polarity on one of the pairs to get them to work as expected or you need to write alternative code that handles this.
I can't think of a reason why it would not work if you connect your driver directly to the Arduino.
The use of JimboZA's L297 might make it easier to control the motor, and will probably save you some pins.

I Googled on your behalf and found this which may help.

Seems it can be done: he provides a function called "step" and the faster you call it, the faster the motor goes. "Step" takes as an argument a 0 or 1 for direction. So he's doing in software, what the 297 does in hardware, I guess.

Hi Jimboza,

Just so we know we're on the same page, I am writing an android app to control the arduino via bluetooth so I won't be programming the arduino directly but rather send and receive signals via the bluetooth module mounted on top of the arduino uno r3 via an android app. Can I still do this then with that modification for the L298? You mentioned it was a software modification on the arduino so I'm a bit confused now

There must be a program (known in Arduino-speak as a "sketch") in the Arduino, otherwise it's just a lump of plastic and silicone. You can't not program the Arduino directly; it has to have a program in it or it's not going to do anything. Loading a sketch isn't a "software modification" as you put it, in the sense that it's anything outside the norm: loading a sketch is a necessary part of using an Arduino.

A typical sketch does three things: it reads a sensor, decides what to do, and outputs signals to do that. Yours is exactly like that:

  • listen for the BT signal,
  • decide what to do with that signal (perhaps an "F100" means forward the stepper 100 steps, "R50" means 50 steps reverse.....),
  • then (if you used the method in the sketch I linked) pulse the stepper the right number of times using the "step"

So yes, what you want to do is pretty feasible.

(BTW, even if you don't use that software approach to running ther stepper, and used an L297, you would still have to have an Arduino sketch listening and acting on the BT message; that sketch would just pulse the 297 which in turn would control the 298.)

Jimboza thank you very much for clearing that up. You have answered some fundamental questions thank you.

So can I use that guy’s code and just “upload” it to my arduino and expect it to control my motor as a stepper? Right now my bluetooth module has 2 pins called Rx and Tx which is connected to my arduino to digital ports (pwm) 10 and 11. So I assume my arduino sketch will read from port 10 and write to port 11 in order to communicate with my phone via bluetooth?

It's not quite that simple, alas....

If you upload that sketch it will allow you run the motor yes, in a basic sense. You would have to make changes to it to make it do the specifics of what you need the motor to do. In particular, that sketch will not listen for BT input, which is not the purpose of that sketch.

You would need to find a sketch that listens for BT, and get it to some simple stuff when it receives some kind of signal from the other part of your project. You may find something about that here in the playground.

Then, you would need to combine those sketches into one: your new sketch will then listen for whatever you send over BT, decide what to do, and then control the motor.

If you haven't already done so, I think you need to work through some of the example in the tutorial

Thank you Jimboza. I will try to look for some sketches that are meant to read from the BT module and control a stepper motor. Once I find and get the sketch working I will go and work on the android app to send signals to the BT. I hope this goes well.