Cant control speed of dc motor with potentiometer
I am trying to control the speed of my dc motor with my potentiometer. But when I turn the potentiometer to max it works but when I turn it a little bit the dc motor turn off. Any idea why?

/*
Arduino | coding-help
Sloth 9/8/25 — 2:34 AM
*/
int potpin = A0;
void setup() {
Serial.begin(9600);
Serial.println("Get pot value test!\n");
}
void loop() {
int potval = analogRead(potpin);
int setSpeed = (potval / 1023) * 255;
int mappedSpeed = map(potval, 0, 1023, 0, 255);
Serial.print("potval: ");
Serial.println(potval);
Serial.print("setSpeed: ");
Serial.println(setSpeed);
Serial.print("mappedSpeed: ");
Serial.println(mappedSpeed);
Serial.print("\n");
delay(1000);
}