stopping DC motor in same place of another motor

I have two DC motors and pots i need to make the second motor stops at the same place of first one
the code I did is as follows
#include <LiquidCrystal.h>
LiquidCrystal lcd(2 , 4 , 5 , 6 , 7 , 8);
// custom degree character
byte degree[8] = {
B00110,
B01001,
B01001,
B00110,
B00000,
B00000,
B00000,
B00000,
};
int lcdrw=3;
const int pot1 = 8;
const int pot2 = 9;
const int pot3 = 10;
const int pot4 = 11;
int tube_deg = 0;
int butfw1 = 22 ;
int butbw1 = 24 ;
int rlyfw1 = 46 ;
int rlybw1 = 48 ;
int rlyfw2 = 50 ;
int rlybw2 = 52 ;
void setup ()
{
pinMode(pot1, INPUT);
pinMode(pot2, INPUT);
pinMode(pot3, INPUT);
pinMode(lcdrw,OUTPUT);
pinMode(butfw1,INPUT);
pinMode(butbw1,INPUT);
pinMode(rlyfw1,OUTPUT);
pinMode(rlybw1,OUTPUT);
pinMode(rlyfw2,OUTPUT);
pinMode(rlybw2,OUTPUT);
digitalWrite (lcdrw,LOW);
lcd.begin(20,4);
lcd.createChar(0,degree);
lcd.setCursor(1,0);
lcd.write("tube:");
lcd.setCursor(10,0);
lcd.write((byte)0);
lcd.setCursor(10,2);
lcd.write("Cm");
lcd.setCursor(10,3);
lcd.write("Cm");
lcd.setCursor(11,0);
lcd.write("DEG");
lcd.setCursor(15,3);
lcd.write("DRS");
lcd.setCursor(2,2);
lcd.write("FID:");
lcd.setCursor(0,3);
lcd.write("Akcir:");
}

void loop()
{

int f =analogRead(pot1);
int r =analogRead(pot2);
int s =analogRead(pot3);
int BS = analogRead(pot4);
long tube_deg = map(f, 500, 530, 0, 90);
long YuksekT = map(r,0,500,0,400);
long YuksekA = map(s,158,750,100,300);
long BS1=map(BS,145,745,100,300);
lcd.setCursor(6,0);
lcd.print(" ");
lcd.setCursor(6,0);
lcd.print(tube_deg,DEC);
lcd.setCursor(6,2);
lcd.print(" ");
lcd.setCursor(6,2);
lcd.print(BS1,DEC);
lcd.setCursor(6,4);
lcd.print(" ");
lcd.setCursor(6,4);
lcd.print(YuksekA);
if ( digitalRead(butfw1) == HIGH)
{
digitalWrite(rlyfw1,HIGH);
}
else if (digitalRead(butfw1) == LOW)
{
digitalWrite (rlyfw1,LOW);
}

if ( digitalRead(butbw1) == HIGH)
{

digitalWrite(rlybw1,HIGH);

}
else if (digitalRead(butbw1) == LOW)
{

digitalWrite(rlybw1,LOW);

}

if ((BS1) < (YuksekA) )
{
digitalWrite(rlyfw2,HIGH);

}
else if ((BS1) > (YuksekA))
{
digitalWrite (rlybw2,HIGH);

}

else {
digitalWrite (rlyfw2,LOW);
digitalWrite (rlybw2,LOW);
}

}
my problem is the motor just going up and down frequently
so it cannot reach the point of first one.
I tried to do average program but it was the same
best regards

You need to go back to your post and modify it so the code is in code tags and looks like this (without any smileys). Use the button that looks like a scroll with <> on top of it. It also makes it much easier to review your code. And you do want to make life easier for us, don't you?

You need to provide a description of what the different parts of your code are supposed to do - it is very time consuming to figure that out from the code.

I also suggest you leave out ALL the LCD stuff until you have the motors working the way you want. It will make the code shorter and easier to follow. At this stage the LCD stuff is just a distraction.

...R

You need a PID control loop or similar to drive one motor from an error signal linearly. Your
code oscillates because you have very high gain (one LSB of the pot value turns the
motor fully on).

You need to take an error value and scale it to produce a drive level for the motor
so it gets less drive as the error reduces, or overshooting is guaranteed.

BTW code like this:

   if ( digitalRead(butfw1) == HIGH)
  {
    digitalWrite(rlyfw1,HIGH);
      }
  else if (digitalRead(butfw1) == LOW)
  {
    digitalWrite (rlyfw1,LOW);
   }

is much simpler written like this:

  digitalWrite (rlyfw1, digitalRead (butfw1)) ;

but the pot still giving me an unstable value due to far distance
is there any amplification to strengthen the signal ???

or i need the changing value of pot (+-2)not to be followed by the other motor

firasalfares:
or i need the changing value of pot (+-2)not to be followed by the other motor

OR, how about giving the description I already asked for?

Then maybe I would know a little more about your project and could think of something useful to say.

...R

thank you for your patient
i can send you video by email
i will tell you my problem as example
the first motor moves to value =30
the second has to change to value = 30 (auto tracking )
but the pot is not giving 30 it is jumping between (29-30) because of position
so my motor is going to 30 and 29 in a frequently way so i need my motor to be stable
i need if the first motor stopped it gave me a value and don;t change it again unless the button is pressed.

firasalfares:
i can send you video by email

Certainly NOT. Do it in public here in the Forum or not at all.

i will tell you my problem as example
...snip...

That is not a description of what the different parts of your program do.

And you have not yet modified your earlier Post to put the code in code tags.

...R