Go Down

Topic: Speed and direction control of dc motor using arduino and l298 (Read 2087 times) previous topic - next topic



I am trying to control both the speed and direction of dc motor using l298. Is speed control possible with l298?

Following is a snippet of my code

digitalWrite(9,HIGH); //Enable

digitalWrite(9,HIGH); //Enable

This works but the motor rotates at a constant speed!

To vary the speed, if I write analog values to pin 5 to move it counterclockwise, it is not working (I keep pin 6 LOW throughout)! Same thing is happening with pin 6!

Any input is appreciated. Thanks in advance.


It seems like your method should work. Perhaps you can try PWM to the ENABLE pin. - Scotty


Thanks scottyjr.

I took a different approach this time and problem is solved!

I am varying the time for which I keep the pins 5 and 6 HIGH. This is taking care of the variation in speed.


What sort of speeds are you able to get?

I tried this method using a delay to hold the pin high. The chip runs too fast for the motor, you have to slow it down. And if delay was a variable, you could control the speed. But I burned out my old shield as it did not have any back-emf protection. I have a new shield now but it is not hooked up yet.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131