Is this while loop wrong ? Its not working after count 1, Please help

It’s not working after displaying " JOB COUNTER 1 Processingm6" even after triggering analog input voltage of 5VDC (HIGH) to A0 pin via Push Button.

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x27 // <<- Add your I2C LCD MODULE address here.
#define Rs_pin 0
#define Rw_pin 1
#define En_pin 2
#define BACKLIGHT_PIN 3
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);
int a = 0;



// SENSORS INPUT PIN CONFIGURATION

const int mts = 13;//mega triggering signal MEGA PIN 53 IS CONNECTED TO UNO PIN 13


// MOTORS PIN CONFIGURATION
// m6 
const int m6p1 = 3;
const int m6p2 = 4;
const int m6p3 = 5;
const int m6p4 = 6;
const int m6sdt1 = 0; // m6 STEPPER MOTOR STEP DELAY TIME 1 REVERSE MOTION

// sl2 JOB NUT RELEASING PULL SOLENOID
const int sl2 = 8;
const int dsl2tmd = 100;//delay sl2 solenoid to move down
const int dsl2tmu = 250;//delay sl2 solenoid to move up

void Uno() // UNO Function
{
lcd.setCursor(0,1);
      lcd.print(a);
      
if (digitalRead(mts) == HIGH)
{
  digitalWrite(sl2, HIGH);
  delay(dsl2tmd);

  //  JOB COUNTING
      a++;
      lcd.setCursor(0,1);
      lcd.print(a);
  


  // m6 ACW Rotation, To bring Nut feeder at its initial position, 1st Use
 while(digitalRead(A0)==0) // A0 Inductive Proximity sensor output connected to A0 pin of Uno
 
  { lcd.setCursor(4,1);
    lcd.print("Processingm6");
    
    digitalWrite(m6p1, HIGH);
    digitalWrite(m6p2, LOW);
    digitalWrite(m6p3, HIGH);
    digitalWrite(m6p4, LOW);
    

    digitalWrite(m6p1, HIGH);
    digitalWrite(m6p2, LOW);
    digitalWrite(m6p3, LOW);
    digitalWrite(m6p4, HIGH);
   

    digitalWrite(m6p1, LOW);
    digitalWrite(m6p2, HIGH);
    digitalWrite(m6p3, LOW);
    digitalWrite(m6p4, HIGH);
    

    digitalWrite(m6p1, LOW);
    digitalWrite(m6p2, HIGH);
    digitalWrite(m6p3, HIGH);
    digitalWrite(m6p4, LOW);
   
    

    
  }
  
  lcd.setCursor(4,1);
  lcd.print("m6 done     ");
  digitalWrite(sl2, LOW); 

  
  delay(dsl2tmu);
}

} // END OF UNO FUNCTION



void setup()
{
/*Serial.begin(9600); // opens serial port, sets data rate to 9600 bps*/

// PIN MODE
pinMode(m6p1, OUTPUT);
pinMode(m6p2, OUTPUT);
pinMode(m6p3, OUTPUT);
pinMode(m6p4, OUTPUT);


pinMode(sl2, OUTPUT);

// 16X2 LCD I2C
lcd.begin (16, 2);
lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
lcd.setBacklight(HIGH);

// JOB COUNTER DISPLAY
{
  lcd.setCursor (0,0);
  lcd.print("JOB COUNTER ");
}

}


void loop()
{

 
  // calling void Uno() // UNO Function
  

Uno();

}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

it works only after removing attachInterrupt(digitalPinToInterrupt(mcipt),Uno,RISING);

but I need interrupt in this code :(

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum Your code is too long for me to study quickly without copying to a text editor.

…R

What is the value of mcipt?

You can't have LCD calls or Serial calls in an Interrupt Service Routine (ISR) because they are slow and they rely on interrupts which are disabled in an ISR. So it is completely impractical to use your Uno() function as an ISR.

In the ISR just set a flag variable so the other parts of your code know that the interrupt has happened.

If all you want to do is detect a human pressing a button there is no need to use an interrupt. Just check the value of the I/O pin in every iteration of loop() and make nothing in the rest of your code prevents loop() from repeating hundreds or thousands of times per second. Maybe look at the demo Several Things at a Time

...R