Hi i set up two ultrasonic sensors and one OLED display with a stepper motor. When i execute the program, the line 'stepperName.step(Steps);' delays the execution of other lines by a long time.
Here is the code:
welcome to the arduino-forum.
well done posting your code as a code-section in your very first post.
You are describing the behaviour of your code. This is good. But this is only a part of the information that is needed to really give help.
"Here is the code"
and that's all is really short.
I will give you an answer that has the same shortness: "Use MobaTools"
That's all.
Now what do you think?
Does it help?
I am pretty sure it does not help.
I'm pretty sure that you agree and will follow the way how to solve your problem mimimum 200 minutes faster.
This requires to invest 20 minutes of your precious time to read how to speedup solving your problems.
Directly after registering you got presented informations how to speed up solving your problem.
You should really read it.
it does exactly what you tell it to, ie it executes a number of steps. During the time that it is doing this nothing else can happen, hence the delay in execution of other code
One way to fix this would be to only execute a single step each time that the code gets to that point and to keep a note of how many times a single step has been executed and stopping when the required number of steps has been executed.
If you did this then the rest of the code will have a chance to run between steps. Note, however, that any delays in the other code will slow down the motor
Implementing this solution using the stepper library would be a good programming exercise for you.
There are other libraries that could do what you want without blocking the running of other code, including this one
Its author is active on the forum if you need help