2

I am using the L298N motor driver for a robotics project to control 4 motors. 2 motors in each input and output terminal. I have this connected to an Arduino Uno which is powered by about 7-8v from NiMH batteries. This battery source also powers a servo with a 470uF capacitor and the L298N board.

I have a strange problem when I use the servo attach method for my servo, only outputs 1 and 2 on the L298N start working meaning the wheels on the left of the robot start moving only. When I have the servo connected and imported the library but don't use the attach method, the L298N outputs to all DC motors meaning it works. Even when I use the servo attach method on a pin where nothing is connected to it, the motors on out 4 and 3 on the L298N don't move. For some reason this attach method is causing issues. Can anyone explain why?

Note: I applied a larger power supply, from my 7V to about 12V but the problem still persists. I don't think power is the issue since the problem even happens when the attach method is called on a pin that has no servo connected to it.

closed as unclear what you're asking by user31481, gre_gor, jose can u c, SDsolar, MatsK Nov 18 '17 at 6:27

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Are you using PWM outputs for driving L298? If there is any of PWM outputs on the same Counter/Timer as Servo, it won't work, as Servo needs different settings for that timer. – KIIV Oct 5 '16 at 18:23
  • what do you mean counter/timer – Don Grey Oct 5 '16 at 21:00
  • 2
    In the microcontroller used in the Arduino Uno, there are three Timer/Counter modules. Each of them has two hardware PWM channels. If you mix up one PWM output and one Servo output, it'll change settings for PWM and it might stop working (thats a problem mainly for Timer1). Pins 3 and 11 are on Timer2, 9 and 10 on Timer1 and pins 5 and 6 are on Timer0 (this one is used for millis() too) – KIIV Oct 5 '16 at 21:43
  • I agree with @KIIV . It seems a problem with Servo library and PWM outputs (specially with pins 9 and 10). – caligari Apr 6 '17 at 2:26
  • 1
    If possible, could you please include your code and your schematic? – sa_leinad May 10 '17 at 13:28