I'm reading the 'Beginning Arduino' book, and now working with Project 15, driving a DC motor and changing the speed of it with a potentiometer.
Now the problem: in the book they say that I need to use a 10kOhms potentiometer, but I don't have that one, so I used an 25kOhm potentiometer.
Now I experience that the motor's speed only changes a little bit with a 25kOhm potmeter, is that normal, and is there a way to let it change the speed more?
I'm using a normal small DC motor that works on 3v.
I don't have that book,so i can't help with the details.
Is the motor too fast or too slow? Do you have a transistor or MOSFET driving the motor?
The 25k pot should work fine. Any pot should work... Except, if the resistance is too low (maybe less than 100 ohms), you'll get excess current through the pot. If the resistance is too high, the input resistance/impedance of the Arduio will interfere with "voltage divider" created by the pot, and the center position won't be "half-speed" (half voltage). But, the minimum will still be zero, and the maximum will still be 5V (assuming it's connected to 5V ).
Also, audio-taper pots are non-linear and the center won't be half-voltage, but again the minimum & maximum will be unaffected.
Is the motor too fast or too slow? Do you have a transistor or MOSFET driving the motor?
It's turning fast, but I don't now it is the fastest it can reach. But I just can't make the motor stop turning with the potmeter.
If the potmeter is fully turned clockwise, and I connect the power source, then the motor starts turning at high speed. If I turn the potmeter fully anti clockwise, then the speed of the motor changes a very little bit.
Okay - What is the pot wired to and how is it wired?
A typical pot has 3 terminals. one for each end of the resistive element and 1 for the wiper.
Make sure one end of the resistive element is connected to 5V and the other to ground. Now as you turn the pat the voltage out the wiper pin should change. This voltage from the wiper would be connected to you analog input. If you have all 3 terminals connected, you probably have it connected wrong.
kf2qd:
Okay - What is the pot wired to and how is it wired?
A typical pot has 3 terminals. one for each end of the resistive element and 1 for the wiper.
Make sure one end of the resistive element is connected to 5V and the other to ground. Now as you turn the pat the voltage out the wiper pin should change. This voltage from the wiper would be connected to you analog input. If you have all 3 terminals connected, you probably have it connected wrong.
Do you have a voltmeter? even a cheap $5 one?
The left pin is going to 5v, the center pin to analog pin 0, the right pin to GND.
// Project 15 - Simple Motor Control
int potPin = 0; // Analog in 0 connected to the potentiometer
int transistorPin = 9; // PWM Pin 9 connected to the base of the transistor
int potValue = 0; // value returned from the potentiometer
void setup() {
// set the transistor pin as output:
pinMode(transistorPin, OUTPUT);
}
void loop() {
// read the potentiometer, convert it to 0 - 255:
potValue = analogRead(potPin) / 4;
// use that to control the transistor:
analogWrite(transistorPin, potValue);
}
const int potPin = 0; // Analog in 0 connected to the potentiometer
const int transistorPin = 9; // PWM Pin 9 connected to the base of the transistor
void setup()
{
Serial.begin (9600);
}
void loop()
{
int potValue = analogRead(potPin) / 4;
Serial.println (potValue);
analogWrite(transistorPin, potValue);
delay (200);
}
Well, AWOL's code confirmed that your pot is working correctly. So your using a 25k pot instead of a 10k pot is not a problem.
Your code looks fine. But it appears that your motor is getting full power, or nearly full power, most of the time. Somehow I think your transistor or motor wiring is wrong. I cannot see anything wrong from your picture. I'll keep looking.
Can you use your multimeter to check your power supply wiring? Make sure that what you think is positive is indeed positive. And what you think is ground is ground.