Pages: [1]   Go Down
Author Topic: Help controlling a DC motor with pot pls  (Read 269 times)
0 Members and 1 Guest are viewing this topic.
U.S.A.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Contemplating 1001010101 since 1994
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 618
Posts: 33952
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Online Online
Brattain Member
*****
Karma: 480
Posts: 18720
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9541
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Global Moderator
Online Online
Brattain Member
*****
Karma: 480
Posts: 18720
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The AnalogInOutSerial sketch that comes with the IDE would assist you in that.
Logged


Manchester (England England)
Online Online
Brattain Member
*****
Karma: 618
Posts: 33952
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I would say the lines top.
IPad auto corrector I typed in "ten lines top"
Logged

Global Moderator
Online Online
Brattain Member
*****
Karma: 480
Posts: 18720
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.damnyouautocorrect.com/
Logged


Pages: [1]   Go Up
Jump to: