Go Down

Topic: How to control DC motor forward and reverse with one potentiometer (Read 8 times) previous topic - next topic

David82


For a motor (with h-bridge/motor shield of course!). You read the pot with ADC and then values above (say ) 700 are forward, values below 300 are backward and values in between are stop. But you still need one pot per motor.

Mark
That looks to be correct. Do you have a link to a recommended h-bridge/motor shield? Remember, I'm simply using a analog, 2-axis joystick (with 2 pots total) to control a pair open-loop motors for use in a pan tilt system. For example, if the joystick is half-way tilted to the right, the pan/tilt system will go half-speed in that direction. I've done this plenty of times with servos but now the components need to be basic, dc motors.

HazardsMind

#16
Dec 04, 2012, 03:46 pm Last Edit: Dec 04, 2012, 04:00 pm by HazardsMind Reason: 1
Quote
I've done this plenty of times with servos but now the components need to be basic, dc motors.


Then my solution is the one you want to use.

It gets data from the 2 pots and tells the motors how to move.If you dont like my second way, then just repeat my first way for both motors.

This controls the forward and backwards movement of ONE motor, repeat for second motor.
Code: [Select]
// say the lowest is 350 and the highest is 650, the difference is 300
// so divide 300 by 2, you get 150.
// then 350 + 150= 500 (center)
//offset, you decide how much dead zone you want, for the center.
// +-10 should be enough.
If( POT1< 490) { // offset(10) - center(500)
...go forward...
}
Else if (POT1 > 510) {
... Go backwards...
}
Else {
... Full stop...
}
Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

holmes4

Which motor shield depends on how much current the motors would require. Take a look and the Arduino one in the hardware section of the main site as a starter. This runs two motors each with speed and direction (4 digital pins in all).

As for the pots one end to earth one to the 5v and the center wiper to the analog pin.

Mark

AWOL

Quote
This runs two motors each with speed and direction (4 digital pins in all).

You may also want to add another couple of pins for the brakes.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

holmes4


Go Up