(sorted out)need programmer i will pay $$$

hello...1st sorry about my language,it is not my 1st language...i looking for programmer who can write proper code
that is parts what i use:

  1. arduino nano v3.0

2)Stepper motor nema 17 or nema 24 (1.8 degrees,200 steps per revolution)

3)Stepper motor driver Toshiba tb 6600,but can use A4988,because do the same things

  1. 2 limit swiches

  2. 2 SPST momentary Push Button(but i won it only one or 3 (forward,stop,backward))

about project i won it movable table which has two position FRONT (stopped by 1st limit switch) ,BACK ( stopped by 2nd limit switch) and only one PUSH BUTTON wich controlled direction: example if press once MOTOR DIRECTION ==LOW move stepper motor to front position(front limit) ,and 2nd press change MOTOR DIRECTION == HIGH move back position(back limit).any press of button change direction like 1 2 1 2 1 2 contiously...if do not have any other press than moving stopped when limit is hit..and example button press and move to forward and direction is ==HIGH and hit back limit stops and do nothing before button not pressed change DIRECTION only to ==LOW

i have example code.when turn on automatic send to front position(front limit) and stops,when press button back sent to back position(back limit) and stops.when press front button send to front position(front limit) and stops...but if i press front button and send to front limit and i press other back button stopped working and has very big noise,and can not do anything like turn off controller and turn again on...and other problem when limit is hit example front and i press the same front button,start to breaked limit...i won it new code and that take only like example how should to work,and what i mean...i hope someone to understood what i won it...

about pay,waiting for your offer

moving_table.ino (3.8 KB)

PORTD |= _BV(PD7); //digitalWrite(motor_step, HIGH);
delayMicroseconds(stepSpeed); //stepSpeed
PORTD &= ~_BV(PD7); //digitalWrite(motor_step, LOW);

part of the problem might be that you have a delay after setting the motor step to HIGH, but there is no delay after setting the motor_step to LOW. The next loop happens within microseconds, so if the motor needs to be moving it is only getting that LOW signal for a very brief period of time.

I don't know why you are using ports. Just using pinMode() and digitalWrite() should be more than fast enough.

Anyway. Try this:

/*
  DESCRIPTION
  ====================
  Simple example of the Bounce library that switches the debug LED when a button is pressed.
*/
// Include the Bounce2 library found here :
// https://github.com/thomasfredericks/Bounce-Arduino-Wiring
#include <Bounce2.h>

#define btnFront 4
#define btnBack 5
#define motorDirection 6
#define motorStep 7
#define limitFront 9
#define limitBack 11

int stepSpeed = 450;   // stepper driver motor speed.Lower is faster

// Instantiate a Bounce object
Bounce debouncer_btnFront = Bounce();
// Instantiate another Bounce object
Bounce debouncer_btnBack = Bounce();
// Instantiate another Bounce object
Bounce debouncer_limitBack = Bounce();
// Instantiate another Bounce object
Bounce debouncer_limitFront = Bounce();

enum Direction {
  FRONT, BACK
} direction;

void setup() {
  //set up the various outputs
  DDRD |= _BV(PD6);  // pinMode(motorDirection, OUTPUT);
  DDRD |= _BV(PD7);  // pinMode(motorStep, OUTPUT);

  // Setup the first button with an internal pull-up :
  pinMode(btnFront, INPUT_PULLUP);
  // After setting up the button, setup the Bounce instance :
  debouncer_btnFront.attach(btnFront);
  debouncer_btnFront.interval(5); // interval in ms

  // Setup the second button with an internal pull-up :
  pinMode(btnBack, INPUT_PULLUP);
  // After setting up the button, setup the Bounce instance :
  debouncer_btnBack.attach(btnBack);
  debouncer_btnBack.interval(5); // interval in ms

  // Setup the second button with an internal pull-up :
  pinMode(limitFront, INPUT_PULLUP);
  // After setting up the button, setup the Bounce instance :
  debouncer_limitFront.attach(limitFront);
  debouncer_limitFront.interval(5); // interval in ms

  // Setup the second button with an internal pull-up :
  pinMode(limitBack, INPUT_PULLUP);
  // After setting up the button, setup the Bounce instance :
  debouncer_limitBack.attach(limitBack);
  debouncer_limitBack.interval(5); // interval in ms

  // when the sketch starts, we want the platent to go to the front position
  direction = FRONT;
  PORTD &= ~_BV(PD6); //digitalWrite (motor_direction, LOW); //move to frontPosition
}

void loop() {
  // Update the Bounce instances :
  debouncer_btnFront.update();
  debouncer_btnBack.update();
  debouncer_limitBack.update();
  debouncer_limitFront.update();

  // Get the updated value :
  int value_btnFront = debouncer_btnFront.read();
  int value_btnBack = debouncer_btnBack.read();
  int value_limitBack = debouncer_limitBack.read();
  int value_limitFront = debouncer_limitFront.read();

  if (value_btnFront == LOW) {
    direction = FRONT;
    PORTD &= ~_BV(PD6); //digitalWrite (motor_direction, LOW); //move to frontPosition
  }
  else if (value_btnBack == LOW) {
    direction = BACK;
    PORTD |= _BV(PD6); //digitalWrite(motor_direction, HIGH);// move to backPosition
  }

  if (
    (direction == FRONT && value_limitFront == HIGH) // need more to front
    ||
    (direction == BACK && value_limitBack == HIGH) // need more to back
  ) {
    PORTD |= _BV(PD7); //digitalWrite(motor_step, HIGH);
    delayMicroseconds(stepSpeed / 2); //stepSeed
    PORTD &= ~_BV(PD7); //digitalWrite(motor_step, LOW);
    delayMicroseconds(stepSpeed / 2); //stepSeed
  }
}

If your problem is fixed, could you post an explanation here for how you fixed it? This will be useful and instructive for anyone reading this thread.