1

I have a DC motor connected to a L298N (Green) controller. The controller is receiving electricity but the motors aren't. This is how we wired everything

enter image description here

Our code:

#include <SoftwareSerial.h>

int IN1 = 13;
int IN2 = 12;

int IN3 = 8;
int IN4 = 9;

void setup(){
  Serial.begin(9600);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  
  
}

void loop(){
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  delay(2000); 
}

The DC motor is not responding at all

Edit: Why is the motor not receiving electricity? How can we connect the card to the Arduino UNO correctly and get the motors running?

8
  • How exactly are you powering the Arduino? Over USB? Or over the 5V pin of the L298N? Has your L298N board a 5V voltage regulator? If you are trying to power the Arduino from the 5V pin of the L298N, you should use the 5V pin of the Arduino instead of the Vin pin (since that is connected to the linear voltage regulator)
    – chrisl
    Jan 27, 2022 at 19:16
  • And are you really using a single 3.7V battery to power it all?
    – chrisl
    Jan 27, 2022 at 19:17
  • @chrisl The arduino is powered by USB and L298N is connected to a 9V battery via VCC. Jan 27, 2022 at 19:17
  • 1
    1. Then please remove the connection to Arduino Vin. It is not needed (since you power over USB), neither does it work (on Vin you need about 7V to get it working reliably). 2. Are you using one of these standard 9V block batteries? If yes, then this is a problem. They are not build for providing enough current (like for motors). They are made for low current applications (like smoke alarms).
    – chrisl
    Jan 27, 2022 at 19:35
  • Please also provide a link to the exact L298N board, that you have.
    – chrisl
    Jan 27, 2022 at 19:36

1 Answer 1

3

First: The connection between the 5V pin of the L298N and Arduino Vin is not correct here. The L298N 5V pin is an output. You could use it to power the Arduino. But then you would have to connect it to the 5V pin of the Arduino. Vin is connected to the linear voltage regulator. You need about 7V here to get the Arduino running reliably, because the regulator needs some headroom for regulating it down to 5V and the battery deplets over time a bit. Since you are powering the Arduino over USB you can remove this connection.

Second: The standard 9V block batteries, that you use, are not meant for providing the power for something like a motor. They are made for low power applications (like smoke detectors). So you will need a different battery type. Which exactly is dependent on further factors. You could start with putting AA batteries in series (enough to get to the voltage, that you need for your motors). Or you can buy a LiIon or LiPo battery (including the corresponding charging board). I'm not enough of a battery expert myself to go more detailed with the recommendations on direct batteries.

If you want it easy you might want to use a standard USB power bank. These give you 5V and (depending on the product) about 1 or 2A of current. Using a standard power bank has the advantage, that you get well regulated voltage, relatively high current and it already has the correct charging electronics.

With a USB-C power bank a corresponding PD board (Power Delivery) you can even get up to 12V from the power bank. Haven't tried this myself yet. Have a look at this video from GreatScott on Youtube. Looking at a standard online marketplace (we all know which one) and searching for "USB-C PD board" gave some promising results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.