Help! L298N Dual H-brigde, Arduino uno and at bipolar stepmotor

Hi :slight_smile:

I am completely new to Arduino and electronics at all, and therefore have i ran in to some problems in connecting an Arduino Uno and the Seeedstudio L298 Dual H-brigde and a bipolar stepping motor.

Currently i have connected the 1I to pin 8, 2I to pin 9, 3I to pin10 and 4I to pin 11.

The signal EA is connected to pin2, and EB to pin3.

Basically its:

//H-Bridge pins
int. I1 pin 8
int. I2 pin 9
int. I3 pin 10
int. I4 pin 11
int speed. EB pin 4 //PWM
int speed EA pin 2 //PWM

The Arduino Sample that i have loaded on to my Arduino is the sample sketch from the library.

Stepper Motor Control - one revolution

This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.

The motor should revolve one revolution in one direction, then
one revolution in the other direction.

Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe


#include <Stepper.h>

const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);

void setup() {
// set the speed at 60 rpm:
// initialize the serial port:

void loop() {
// step one revolution in one direction:

// step one revolution in the other direction:

I know that this input is not enough but I don’t know how to write a proper program… so basically my question is: Is this setup correct and how could i alter the sketch so it fits my purpose, which basically is to make to motor spin 60 steps oneway and then 60 steps back the other way.

I apologize if theres any misspellings or sentences which are hard to understand since english is not my native language.

Best regards Mathias.

The H-brigde:

Stepping motor:

it’s a 42mm high torque hybrid stepping motor, with a step angle of 1.8 degrees.

Arduino Uno:

You need to connect the enable pins HIGH I think - if you've connected them to 2 and 4 then

  pinMode (2, OUTPUT); digitalWrite (2, HIGH) ;
  pinMode (4, OUTPUT); digitalWrite (4, HIGH) ;

Or you can wire them to +5V.

BTW note the code tags that can be used to include code examples as above (the # button)

[ Also did you say bipolar? And you're using Stepper.h - go read the documentation about how to wire a bipolar motor for the Stepper library, I think you've got the wrong circuit ]

Thank you very much :slight_smile:

I will try to do so, and see if I can make it work :slight_smile: