Problem getting the correct speed on my NEMA17+A4489+potentiometer project

analogRead takes a significant amount of time (around 100us).
You need to take that into account.