This is my first time using Arduinos (and coding...) and my project is basically to control the speed of a small 12V computer fan using a potentiometer. I have plugged a 12V battery pack into the Arduino shield and a computer fan in the A ports. What I'm observing is that the fan would only turn when the output setting is at 255 and will not turn and any other output, like 250, 150 etc. I have tested the same code/setput with a 6V DC motor , changing the battery pack to 6V, and the system works. My hypothesis is that the output voltage at A port was not 12V, and was in fact 5V, like for the Arduino, but I have no idea if this really is the case and if it is, how to fix it...
I have tried Google, but I guess my main problem was I'm not sure what I'm looking for...
I have attached a picture of the layout and copied the code below.
void setup() {
//Use Channel A
pinMode(12, OUTPUT); //Controls motor direction
pinMode(9, OUTPUT); //Initiates motor break
Serial.begin(9600);
}
void loop(){
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
int potValue = analogRead(A2);
int motorvalue = map(potValue, 0, 1023, 0, 255);
analogWrite(3,motorvalue);
Serial.println(motorvalue);
delay (100);
}