I have a question. I have seen video-tutorial where people controlling the position of a stepper motor with rotary encoder. I have also seen video-tutorials where people control the speed of a dc brushed motor with rotary encoder, BUT i have never seen a video in which someone control the speed of a stepper motor with rotary encoder.
What I want to do is this. With one rotary encoder to control the position of a stepper motor. If a button pressed (even in rotary encoder or an external one) then the rotary encoder to control (both direction) the speed (continues speed) of the stepper motor and not the position. If the button pressed again, then again the position and vice versa.
Forgive me if my question is a bit silly, but I'm new and try to learn.
OK, it seems like you've got some complex states there, switched by the button. Why don't you try to get the speed-control part working first, then work on the button state machine?
Depending on your code (which we can't see) you may be simply issuing a click to the stepper each time the encoder clicks or you may be keeping track of the total number of clicks with a position variable. First, you need to get that position variable and give it a better name - like encoderPosition. That will keep track of how many clicks left or right the encoder has done.
Then map that encoderPosition into a speedCommand. Maybe you want 20 steps per second per encoder click. This should be a simple multiplication or a map() function. Then use a stepper library such as AccelStepper to send that speed to the stepper.
At the end of the video, when the button is pressed, the stepper moto returns to its initial position. What I want to do is when the button is pressed the rotarty encoder (and this blue wheel in the video) to change function and control the speed of the motor (like if I use a potentiometer) insted of the position. Is it possible with rotary encoder to control speed of a stepper motor ?
If yes then I will try with the code, and I ll be back