Go Down

Topic: Potentiometer hogs voltage? (Read 664 times) previous topic - next topic

XistenZ

Hi, I started fiddling with my Arduino I got about a year ago (time, who got it?) and I want to try out different things, one step at a time to get aquainted to my new friend.
I want to control a motor using a potentiometer, and from what I gathered what a potentiometer is is that it let current through. From EVERYTHING to NOTHING. If I hook up a motor to the potentiometer it will start to buzz after a few turns, then stop buzzing when I hit the end. I have a ginormous motor that actually works using the same setup, but it's the smaller (super fast little motors) that won't work. If I hook them up directly to the 3.3v on the Arduino they spin up fine.
So! Why won't they work when having a potentiometer in between, that's fully "open"? And how would I make it work? Any tutorial demands you use some kind of shield and a gazillion other stuff that just seems to be there to make a mess of things.

JimboZA

I can't visualise what you mean when you say you "hook up a motor to the potentiometer ", so we really need a schematic to understand. Well, I do....

And when you say you run a motor directly off the Arduino's 3.3V, you are doing at least two things wrong that a shield will prevent. First, probably pulling too much current direct from the Arduino: a shield (or just a transistor) will switch the power supplied from another source. Second, you run the risk of frying your Arduino with back emf from the motor: a flyback diode such as one in a shield, will prevent that.

Also, without a shield (or an h-bridge standalone), you can't reverse the motor's direction.
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

weedpharma

It sounds like the potentiometer is being used to vary the voltage from the wiper to the motor as there is no reference to it being connected to an analogue pin or to PWM.

We need a better description or a drawing.

Weedpharma

XistenZ


So this is how my setup looks. The potentiometer is connected to Analog 0, power and ground. The motor is connected to digital pin 11 and ground.
Everything is connected on a breadboard, forgot to draw the square to simulate it :) hope it makes sense.

My arduino code:
Code: [Select]
int analogInPin = A0;
int analogOutPin = 11;

int sensorValue = 0;
int outputValue = 0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  sensorValue = analogRead(analogInPin);
  outputValue = map(sensorValue, 0, 1023, 0, 255);
  analogWrite(analogOutPin, outputValue);
 
  Serial.print("sensor = " );
  Serial.print(sensorValue);
  Serial.print("\t output = ");
  Serial.println(outputValue);
  delay(10);
}

weedpharma

It is not a good idea to run the motor from the Arduino pin. It may overload the pin and damage the arduino.

Also the motor may cause voltage spikes that could also damage the Arduino.

Use a mosfet to drive the motor. There are many posts on doing this.

Weedpharma

JimboZA

There have been posts in the past that say even those tiny vibrating motors like in cellphones draw too much current for an Arduino i/o pin which should be kept below 20mA.

If you have an ammeter, measure the current that motor draws at startup and it will almost certainly be too high.

Transistors, h-bridges, diodes, shields, and "and a gazillion other stuff that just seems to be there to make a mess of things" exist for a reason.
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

weedpharma

Try a NTD5867NL. It is a logic level gate N type that is cheap and handle a few amps easily.
I got mine from RS Components.

Weedpharma

Grumpy_Mike

And don't forget the diode across the motor when you do wire it up correctly.

See:-
http://www.thebox.myzen.co.uk/Workshop/Motors_1.html

Go Up