Ive a question that im breaking my head over.
I have a stepper motor (controlled with easydriver) that I control with 3 buttons (left, right, stop) and a potmeter for speed.
Now I want to implement the following thing, but I cant figure out how:
Imagine a camera slider:
begin end
** X-------------------------X**
I want to move the stepper motor around, and when im satisfied at a position (position A) I can press a button and it "saves" the position.
begin end
** X----A--------------------X**
Then I move it further until position B, press a button again and it "saves" position B
begin end
** X----A----------------B---X**
Now if I press another button, it will go from B to A, or from A to B. So i can replay the positions (pendle between the positions that I saved). How can i create this?
Im frying my brains
What you describe is certainly possible and not especially difficult. What you have not told us, however, is how long you want your Arduino to remember the A and B positions. Maybe you create them new every time to restart the Arduino? Or maybe you want the Arduino to remember them from one session to the next. If the latter you need to save the positions into the EEPROM memory.
Assuming you have some code to make the stepper motor go to the HOME position at startup then when you move to positionA and press the button to save that position you can just store the current position in a variable - perhaps positionAvalue. Do the same for positionB.
Then you can have another piece of code that moves to the positionAvalue when you press the appropriate button.
It may help to have a switch (or button) that toggles between learning mode and operating mode. That way the same buttons could perform different functions depending on the mode.