Having trouble with a potentiometer controlling some LEDs

but I would suggest you try changing:

val = analogRead(potPin);
val = map(val, 0, 1023, 0, 25);

to something like

int valPot=0;

valPot = analogRead(potPin);
val = map(valPot, 0, 1023, 0, 25);

Why? The codes are functionally identical, except the second wastes and extra int (and sets it to zero unnecessarily).