Need Help In Arduino Uno, L298N and Dc Motor

BTW, what is the voltage rating of your motor ?

I dont Know, I am using the motor that came with

Do you have a jumper on the M1 ENABLE header pins ?

yes. is it neccessary to put on both or only the one facing towards outwards. Bye gotta go..

Try this simple sketch: (NOT TESTED)

Arduino to motor driver header connection:

Arduino pin A0 connect to wiper of the joystick

Arduino pin 2  connect to IN1
Arduino pin 3  connect to IN2
Arduino pin 9  connect to ENA A (motor 1 enable)
int Xpin       = A0; //connect to wiper of the joystick
int m1Pin1     = 2;  //connect to IN1
int m1Pin2     = 3;  //connect to IN2
int m1SpeedPin = 9;  //connect to ENA A (motor 1 enable)

int Xval;
int m1Speed;

void setup()

  pinMode(m1Pin1, OUTPUT);
  pinMode(m1Pin2, OUTPUT);

  pinMode(m1SpeedPin, OUTPUT);
  analogWrite(m1SpeedPin, 0);

  digitalWrite(m1Pin1, HIGH);
  digitalWrite(m1Pin2, LOW);

void loop()
  Xval = analogRead(Xpin);

  m1Speed = Xval / 4;
  analogWrite(m1SpeedPin, m1Speed);

  Serial.print(" m1speed = ");


Remove the ENA and ENB jumpers for regular motor operation when using analogWrite to control these pins for PWM speed control.

I can't understand what to do. I have removed the jumpers and it a wire on them

**You need to make these connections from the Arduino to the Motor Controller header.**

Try the sketch I offered you.

Arduino pin 2  connect to Motor Controller   IN1
Arduino pin 3  connect to Motor Controller   IN2
Arduino pin 9  connect to Motor Controller   ENA A (motor 1 enable)

I hav already made connections. I am trying to control my motor using joystick

please tell if I should use code in post 43 or post 48

I have tested this code and it worked in serial monitor just the way I wanted it to. Is there any thing wrong in this. Xval and Ubal are of joystick

The sketch in post 48 is just to check to see if the motor speed can be controlled.

Did the sketch from post 48 control you motor speed ?

Let me try. I seem to have misplaced my L298d