Min menu

Pages

DC motor with Arduino Uno using L298N



DC motor with Arduino Uno using L298N

 In this Arduino instructional exercise, we will figure out how to control DC engines utilizing an Arduino Uno. Moreover, we will have a total audit of the various techniques to interface a DC engine/different DC engines with the Arduino Uno utilizing L298N and L293D engine driver ICs. You can utilize the route table to look down to the code to interface DC engines with the Arduino. Notwithstanding, we would a lot of demand you understanding the idea first. We should start! 

example:



Pins of L298N IC 



The module has two screw terminal squares for the Arduino DC engine An and B, While another screw terminal square is for the Ground pin, the 12V VCC for engine, and a 5V pin, in any case, it can either be an information or yield. 



It has four computerized input pins for Arduino engine control. Notwithstanding advanced pins, it likewise has two simple information pins for controlling the speed of the engine. 

Appraisals of Arduino engine regulator – H-connect L298N IC

  • Input voltage: up to 40 volts.
  • Output current: up to 3A
  • Power: 25W
  • Moreover, it has two built-in H-bridge, high voltage, large current, full-bridge driver, that can be used to drive DC motors, stepper motors, relay coils, and other inductive loads.
  • Using a standard logic level signal to control.
  • Furthermore, it can drive a two-phase stepper motor or four-phase stepper motor, and two-phase DC motors.
  • Above all, it can adopt a high-capacity filter capacitor yet a freewheeling diode that protects devices in the circuit from being damaged by the reverse current of an inductive load, enhancing reliability
  • Drive voltage: 5-35V
  • logic voltage: 5V

Code for interfacing a single DC motor with an Arduino Uno using L298N

const int rpm = 2 ;

const int in1 = 3 ;

const int in2 = 4 ;

void setup()

{

pinMode(rpm,OUTPUT) ;

pinMode(in1,OUTPUT) ;

pinMode(in2,OUTPUT) ;

}




void loop()

{

digitalWrite(in1,HIGH) ;

digitalWrite(in2,LOW) ;

analogWrite(rpm,255) ;


//Clockwise for 3 secs

delay(2000) ;

//For brake

digitalWrite(in1,HIGH) ;

digitalWrite(in2,HIGH) ;

delay(1300) ;


//For Anti Clock-wise motion - IN1 = LOW , IN2 = HIGH

digitalWrite(in1,LOW) ;

digitalWrite(in2,HIGH) ;

delay(2000) ;

//For brake

digitalWrite(in1,HIGH) ;

digitalWrite(in2,HIGH) ;

delay(1300) ;

}
You are now in the first article
reaction: