1

I have a very weird problem, at least it seems to me that way. I have connected L298N motor driver, Arduino and a hobby servo with a 6v power supply (tested with both 4xAA and 9v alkaline batteries). And wrote a simple program to rotate the servo every 10ms. There are no other motors connected as of yet.

  1. Power supply is connected to the L298N 12v and GND.
  2. Arduino is connected to the 5v and GND of L298N driver with the Vin and GND of Arduino respectively.
  3. Servo's power (red wire) is connected to L298N 5v, GND is connected to the L298N's GND, and, servo's control (orange wire) is connected to pin 9 of Arduino.

The problem is that the servo hardly moves when Arduino gets power supply gets from the Vin input. However, if I connect it to the 5v of the Arduino power it works as expected. But I was under the impression that 5v pin of Arduino was to for the output and not for the input power supply. Could you guys please tell me what am I doing wrong here?

enter image description here

3
  • 2
    Could you draw a simple drawing for your circuit ?
    – R1S8K
    Oct 6, 2020 at 9:25
  • @R1S8K I have updated with a simple circuit. Please have a look.
    – Kakar
    Oct 6, 2020 at 17:56
  • OK, let articulate my answer in answers section, and let me know if there's something need to be modified in my answer.
    – R1S8K
    Oct 9, 2020 at 11:38

2 Answers 2

2

The Vin pin on the Arduino Uno board is connected to the input of the 5V onboard voltage regulator of the Arduino board.

This voltage regulator needs an input voltage that’s about 1.5V above its (regulated) 5V output that will feed the Arduino.

Arduino - note the recommended values of the Input Voltage (7-12V)

If you feed 5V into Vin, the voltage drop on the internal regulator will cause the Arduino board to be supplied with only about 3.5V, which is probably enough to make it function, but not enough to control the servos.

The solution, as you already found out, is to feed the 5V from the L298N board directly into the 5V pin of the Arduino. Please take care to measure the actual voltage from the L298N before you do this (it should be 5 Volts). Alternatively you could connect 12V to the Vin pin of the Arduino, but again, make sure you know what you’re doing.

2
  • 1
    Yes, on researching about the issue, I saw Vin drops 1.5V, that is why I tried with a 9v battery hoping it would at least provide 7.5V. Now I'm thinking that 9V batteries awful. Am I correct?
    – Kakar
    Oct 6, 2020 at 17:59
  • @Kakar 9 V batteries are very good in smoke detectors where they only need to supply a few milliamps ... they are made of six AAAA cells in series
    – jsotola
    Oct 7, 2020 at 2:56
0

You are using Arduino to drive one servo motor and that's simple with only using arduino board with this setting:

  1. 5V supply pin
  2. GND pin
  3. any pwm pin

Now using the LM298N here isn't optimal. If you googled LM298N, you would get the main application of this driver which is to drive DC and stepper motors.

For driving multiple servo motors, you can use this module board to drive upto 16 servo motors.

PCA9685 16-Channel PWM Driver

Here is a link for it on Banggood.

PCA9685 16-Channel 12-bit PWM Servo Motor Driver I2C

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.