Go Down

Topic: How to count the number of steps a stepper motor has made and update it on LCD? (Read 9540 times) previous topic - next topic


Its working properly. But the only thing I am having trouble with, is to update the lcd screen everytime the motor takes the steps entered by the user. And secondly I want to run the motor according to the speed entered by the user. Not to run it at a constant speed.


IMHO you need to rewrite the code to separate the different activities. Your code in loop() could be as simple as
Code: [Select]
void loop() {

Have a look at Planning and Implementing a Program

With the code for the different activities in different functions it will be much easier to manage and to change one part without screwing up another.

If you want a responsive program you MUST get rid of all the delay()s and use millis() to manage timing without blocking. That is illustrated in the above link and in the demo Several Things at a Time

Two or three hours spent thinking and reading documentation solves most programming problems.


Go Up