how to determine the zero point and end [stepper]

hello everyone!

I am newbie in arduino, i try to make macro rail, and i wonder how to make program like this:
Two buttons are move forward and backward, when i decide that is my start position i press 3 button and its remember it as start, then i move forward for eg. 3mm and then press 4 button and this is mine end. When i press 5 button its back to start position and when i press 6 button it goes to the and...

i hope You understand me what i mean, i will be glad for help

I think it would be easier to understand if you provided whatever code you currently
have - or at least some details like which pins are which buttons.

thx for reply,

#include <LiquidCrystal.h>



const int ilosc_krokow_na_obr = 200;
const int skokSruby = 1;
int dir = 3;
int step = 2;
float mikroMetry = skokSruby / ilosc_krokow_na_obr;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  // initialize the serial port:
  Serial.begin(9600);
  pinMode(3, OUTPUT);
  pinMode(2, OUTPUT);
  lcd.begin(16, 2);
}

void krok(boolean kierunek, int ilosc_krokow) {
  int krk; 
  float mm;
 if(kierunek == false) { digitalWrite(3, HIGH);}
if(kierunek == true) { digitalWrite(3, LOW);}
 for(krk = 0; krk < ilosc_krokow; krk++){
digitalWrite(2, LOW);
   delay(5);
  digitalWrite(2, HIGH);
  delay(5);
  mm = krk * mikroMetry;
  lcd.setCursor(0, 1);
  lcd.print(mm);
 }

}


void loop() {
 // digitalWrite(3, HIGH);
//  digitalWrite(2, LOW);
  //delay(50);
//  digitalWrite(2, HIGH);
  //delay(50);
  krok(true, 500);
  
  //krok(false, 500);
}

i want to insert ir remote liblary but i dont know how to determine this start and end point, anyone ? can help me ?

i want to insert ir remote liblary

So, why don't you?

but i dont know how to determine this start and end point

Start and end of what?

Start by including the IR library, and making the sketch simply print "Switch n pressed", where n corresponds to the value on the switch. Then, you can do different things when switch n is pressed. One thing you will need to do is keep track of how many times have been stepped, incrementing or decrementing as appropriate.

#include <LiquidCrystal.h>
#include <delay.h>
#include <IRremote.h>

const unsigned int skok_sroby = 1;
const unsigned int krokow_na_rev = 200;
unsigned int rozdzielczosc;

int krk;
unsigned int pozycja;
unsigned int czesc_calkowita, czesc_dziesietna;

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int RECV_PIN = 12;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
  pinMode(3, OUTPUT);
  pinMode(2, OUTPUT);
  lcd.begin(16, 2);
  rozdzielczosc = (1000 * skok_sroby / krokow_na_rev);
  irrecv.enableIRIn();
}

void wyswietlanie(unsigned int liczba) {
  czesc_calkowita = (liczba / 1000);
  czesc_dziesietna = (liczba % 1000);
  lcd.print(czesc_calkowita,10);
  lcd.print(".");
  lcd.print(czesc_dziesietna,10);
}

void krok(void) {
  digitalWrite(2, LOW);
  delay(5);
  digitalWrite(2, HIGH);
  delay(5);
}

void ruch(boolean kierunek, unsigned int ilosc_krokow) {
  if(kierunek == false) {
    digitalWrite(3, HIGH);
    krk = -1;
  }
  if(kierunek == true) {
    digitalWrite(3, LOW);
    krk = 1;
  }

  for (unsigned int i=1;i<=ilosc_krokow;i++) {
    krok();
    pozycja = pozycja + (krk * rozdzielczosc);
    lcd.setCursor(0,0);
    wyswietlanie (pozycja);
    delay(20);
  }
}

void loop() 
{
if (irrecv.decode(&results)) {
switch (results.value) 
{
case 0x1://kod klawisza 1
ruch(true, 500);
break;
case 0x2://kod klawisza 2
ruch(false, 2000);
break;
}
irrecv.resume();
}

 // ruch(true, 500);
 //delay(1000);
 //ruch(false, 500);
 //delay(1000);
}

i have only something like this…

how now do:

  1. move right if i hold button for eg 4, still move left if i hold 5 and when i stop holding its stop
  2. how to declare start point and end point now ?

help please

move right if i hold button

First, most IR senders send a different value if key is held down. You need to keep track of the previous value, so when the repeat code arrives, you know what to repeat.

Second, steppers rotate. There is NO concept of left or right. The rotation of the stepper may result in some conversion to linear motion, but we can't see how your steppers are doing that. So, you are on your own figuring out what "move right" means, and making that happen.

  1. how to declare start point and end point now ?

The same way as before. Start and end points have no meaning. Steppers rotate. You might want some number of steps to be recorded when a switch is pressed, but until you start counting how many times you've stepped, you haven't a chance of making that happen.