Go Down

Topic: Help controlling a DC motor with pot pls (Read 305 times) previous topic - next topic

maxcamac11

Alright, simply put I have an arduino mega, an L298n H-Bridge motor driver, a DC motor, and a Pot.  I have everything hooked up.  I've looked everywhere on the internet and I know it may be simple as all heck but I cannot for the life of me find the right code to run this thing!  All I want it to do is to stop when the pot is in the middle, turn right and speed up when the pot is going further to the right, and visa versa for the left.  the H-Bridge has four inputs for two motors: 2 are PWM (for speed i'm guessing) and 2 for the polarity of each motor.  Someone please point me in the right direction, I will be forever great-full.

Grumpy_Mike

Quote
All I want it to do is to stop .................

So why are you looking for code why not write it? I would say the lines top.

If the answer is that you can't then how about learning. It opens up all sorts of possibilities and you might actually enjoy it more than trailing through the internet looking to see if some one has done it for you.

Nick Gammon

Quote
I would say the lines top.


?





Tell you what I do, I write the minimal amount of code to make "something happen", then expand on it.

Your first attempt might be to read the pot, and display the values you get on the serial port. That gives you a feel for the numbers you are working with.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

zoomkat

Some search results.

http://www.google.com/search?num=100&hl=en&lr=&tbo=d&as_qdr=all&q=pot+pwm+motor+h-bridge+site%3Ahttp%3A%2F%2Farduino.cc%2Fforum&oq=pot+pwm+motor+h-bridge+site%3Ahttp%3A%2F%2Farduino.cc%2Fforum&gs_l=serp.3...14542.19148.0.20016.8.8.0.0.0.0.54.361.8.8.0.les%3B..0.0...1c.1.Ymgm5AOrluM
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Nick Gammon

The AnalogInOutSerial sketch that comes with the IDE would assist you in that.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Grumpy_Mike


Quote
I would say the lines top.


IPad auto corrector I typed in "ten lines top"

Nick Gammon

Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up