Motor - Button Reverse last command

I am a little desperate...one of my students have desinged a system to to the following:

The first time the button is pressed the motor turns one way for X Turns.
Next time the button is pressed the motor turns the other way for X Turns.

I know I need to store the last value, but really struggling!

HELP!

bool is_start = true;

void loop()
{

   if (button_pressed()) {
      if (is_start) {
         turn_motor_one_way();
      } else {
         turn_motor_the_other_way();
      }
      is_start = !is_start;

   }
}
[code]

Thanks for that...but does anyone actually have to code I can just put my Pins into???

I know I am asking for a lot here!

chap6595:
Thanks for that…but does anyone actually have to code I can just put my Pins into???

I know I am asking for a lot here!

Can’t do that without know your hardware setup! :slight_smile:

I can get the botton to turn on and off the motor, however, i don't know how to get the Board to just get the motor to one turn and then remember the last movment.

What do I need to do this?
Sorry for the novice questions, but really struggling with this!!!

chap6595:
I can get the botton to turn on and off the motor, however, i don't know how to get the Board to just get the motor to one turn and then remember the last movment.

What do I need to do this?
Sorry for the novice questions, but really struggling with this!!!

Again... how have you wired things together? what is your set up? a simple sketch or photo will do