#define motorPin 10
void setup() {
pinMode(motorPin, OUTPUT);
Serial.begin(9600);
while (! Serial);
Serial.println("Speed 0 to 255");
Serial.println("But use 50 to 255 because minimum V required to start the motor is 50");
}
void loop() {
{
if (Serial.available())
{
int speed = Serial.parseInt();
if (speed >= 50 && speed <= 255)
{
analogWrite(motorPin, speed);
}
}
}
}