DC motor control and PWM signal with L298N H-bridge



Arduino Tutorial 28: DC motor control and PWM signal with L298N H-bridge

In this tutorial we will learn how to use the L298N H-Bridge Motor Controller.
We will control the dual DC motor with using the PWM Signals via L298N.
This allows you to control the speed and direction of two DC motors, or control one bipolar stepper motor with ease.

Hardware Required:

Arduino Board - https://goo.gl/Rqc5w2
L298N H-Bridge - https://goo.gl/Ucvx6J
DC Motor Wheel - https://goo.gl/iDy7ep
F to F Jumper - https://goo.gl/TdGrkk
M to M Jumper - https://goo.gl/VRzUN4
Battery Clip - https://goo.gl/iAEgPl

Recomended Site - https://goo.gl/V9nYtx

Circuit Program Fritzing - https://goo.gl/PDBwqe

Get the Code:
const int IN1 = 7;
const int IN2 = 6;
const int IN3 = 5;
const int IN4 = 4;

//const int ENA = 9;
//const int ENB = 3;


void setup() {

  pinMode (IN1, OUTPUT);
  pinMode (IN2, OUTPUT);
  pinMode (IN3, OUTPUT);
  pinMode (IN4, OUTPUT);
  //pinMode (ENA, OUTPUT);
  //pinMode (ENB, OUTPUT);
  // put your setup code here, to run once:

}

void loop() {

  //analogWrite(ENA, 255);
  //analogWrite(ENB, 255); 

  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  
  // put your main code here, to run repeatedly:

}