DC motor with 3(or more) programmed limits

Brinarpi:
Your sketch is in the loop. I dont want a loop, but I need to act on the button press.

I know that. But you need to start with the simplest possible program.

Brinarpi:
Here is the last version with cut out everything possible?

IMHO it still has far too much irrelevant stuff in it.

When I develop a program I do it in the tiniest of steps.

  • Get the motor speed control working based on values in program variables (no user data entry).
  • Add a little bit to read the encoder data and show it on the Serial Monitor
  • Add a little bit more to see if I can use the encoder data to get the motor to stop at a specific place
  • Add a little bit to learn how to ramp the speed up and down depending on the encoder values

Note that none of that has anything to do with buttons. Leave that for another day

...R