control the speed of stepper with a potentiometer and display speed on screen

Hello,

i just started to learn how to use an arduino and I want to control the speed of a stepper motor with a potentiometer and then display the speed on a display. I have a stepper motor, that has 100 steps per revolution. I´m using a 10k potentiometer and a 20*4 display. The driver I use is a simple polulu driver
So far, I can control the speed of the stepper but I don´t no how I can determine the speed of the stepper.
My code is in the attachment. I didn´t use the dir pin because i want the stepper to move in only one way. As you can see, the potentiometer is in the delay(). And I thought that, if i can count the number of revolution of the motor, i could then calculate the speed.

Calculation:

when the step pin is High for a certain time t and Low for the same certain time t (as in the code), so it means that the stepper has 1 revolution in 2*t s (is it right?). I want that the value of the speed changes in function of the value of the potentiometer, given that the potentiometer controls the speed. But I don´t know how the code could like. Can somebody please help me?

sorry, my english is not so good.

Thank you in advance

sketch_mar06a_test_poti_stepper.ino (1.06 KB)

The speed of a stepper motor is determined by the interval between steps. The way your code is written the interval is approximately twice the value of the variable customDelayMapped

I prefer to have a fixed pulse width (about 10 microsecs is usually OK) and vary the interval between steps. See the examples in this Simple Stepper Code.

You will be able to manage the timing more accurately if you use millis() and micros() rather than delay() - as in my second example. By using millis() and micros() you automatically adjust for the time taken by other parts of the program.

...R
Stepper Motor Basics