Is is possible to control a toy DC motor (5V) on an Arduino directly from the Analog (or Digital with PWM) pin without damaging the board? I know that DC motors are usually controlled via a transistor but I am thinking of controlling it this way. My Arduino code is:
void setup() {
pinMode(6, OUTPUT);
Serial.begin(9600);
}
void loop() {
int val = Serial.parseInt();
if( val >= 0 && val <= 1024) {
analogWrite(6,val);
delay(5000);
}
}
My schematic:
GND---------------------MOTOR--------------|<|-------D6 (PWM)