I am trying to control a simple DC motor with a potentiometer. I have pulled from a couple of online places on how to wire and do the sketch. I have setup to see through the serial window that the potentiometer is sending signal for the motor. The motor will not come on. I have verified the motor will work, I have used a volt meter and tell I am getting voltage, but it will not come alive. Attached is a picture of my setup and below is my code. Any help for this newbie will be appreciated.
int potPin = A0; // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the motor
int potValue = 0; // variable to store the value coming from the pot
int motorValue = 0; // varialbe to set the value for the motor
The schematic shows a transistor between Arduino pin 9 and the motor, so the pin is probably OK. However, it also shows the motor powered from the 5V rail of the Arduino which is almost certainly not OK.
After having a day away from it, I figured out what was wrong. I should of been running the (-) to the Transistor. Below is my corrected schematics that is working. The potentiometer controls the motor as I was looking for. I did change one thing in the code.