The playground and youtube haven't been very helpful on this, so I thought it was time to ask it on the forums. I have about a week's experience with arduino and I'm trying to control a DC motor, but it's not working. I don't care about the direction, I'm trying to keep it as simple as possible. I've attached my schematic, is anything wrong with it? When I print out the analog readings from Pin 9, I don't get the values I expect. It always starts off
high, around 900, then drops to around 220 and only move between 210 and 220. So either my schematic is wrong or I've wired it wrong. Here's my code:
int motorPin = 9;
void setup() {
Serial.begin(9600);
}
void loop() {
// Accelerate motor from 0 to 255
for (int i = 0; i <= 255; i++) {
analogWrite(motorPin, i);
delay(10);
Serial.println(analogRead(motorPin));
}
delay(1000);
for (int i = 255; i >= 0; i--) {
analogWrite(motorPin, i);
delay(10);
Serial.println(analogRead(motorPin));
}
delay(1000);
}