I have some trouble for 4x4keypad value and IMU value Compare problem

hello guy:

This is my code Acting:
1.4x4keypad input value print on lcd1602 i2c(this success)
2.IMU input value print on lcd1602 i2c(this success)
3.I hope can keypad input value and IMU input value Compare ,if IMU input value >= keypad input value LED1 HIGH ,else LED1 LOW.(bug)

but i hope can Compare keypad input value and IMU input value ,what wrong with my code?

Thank !!!

#include <Wire.h>
#include <SPI.h>
#include <SparkFunLSM9DS1.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

#define KEY_ROWS 4  
#define KEY_COLS 4  
#define LCD_ROWS 2  
#define LCD_COLS 16 
#define  LED1  5
#define PRINT_CALCULATED
//#define PRINT_RAW
#define PRINT_SPEED 10 // 250 ms between prints
#define password_Length 10
#define DECLINATION -8.58 // Declination (degrees) in Boulder, CO.
LiquidCrystal_I2C lcd(0x27, 16, 2);
LSM9DS1 imu;


char keymap[KEY_ROWS][KEY_COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

byte rowPins[KEY_ROWS] = {13, 12, 11, 10};
byte colPins[KEY_COLS] = {9, 8, 7, 6};
Keypad keypad = Keypad(makeKeymap(keymap), rowPins, colPins, KEY_ROWS, KEY_COLS);


static unsigned long lastPrint = 0; // Keep track of print time




//Function definitions
void resetLocker();
void printAccel();
void clearRow2();


float Vkm;
float vX=0;
bool acceptKey = true;     
char Data[password_Length];
byte data_count=6;
String keyword = "";
char key ;
int  intV,num;
long lastTime=0;





void resetLocker() {
  lcd.clear();
  lcd.print("Set V:");
  acceptKey = true;
  keyword = "";
  lcd.setCursor(0, 1); 
  lcd.print("Real V:");


}

void clearRow2(byte n) {
  byte last = LCD_COLS - n;
  lcd.setCursor(n, 1);

  for (byte i = 0; i < last; i++) {
    lcd.print(" ");
  }
  lcd.setCursor(n, 1);
}


void setup()
{
  Serial.begin(115200);

  Wire.begin();

  if (imu.begin() == false) // with no arguments, this uses default addresses (AG:0x6B, M:0x1E) and i2c port (Wire).
  {
    Serial.println("Failed to communicate with LSM9DS1.");
    Serial.println("Double-check wiring.");
    Serial.println("Default settings in this sketch will " \
                   "work for an out of the box LSM9DS1 " \
                   "Breakout, but may need to be modified " \
                   "if the board jumpers are.");
    while (1);
  }
  lcd.begin();       
  lcd.backlight();  
  pinMode(LED1,OUTPUT);
  digitalWrite(LED1,LOW);
  resetLocker();

  
  
}

void loop()
{
  key = keypad.getKey();
  num=int(key)-48;//ASCLL TRANSFER int
 if (acceptKey && key != NO_KEY){ 
      if (key=='1'||key=='2'||key=='3'||key=='4'||key=='5'||key=='6'||key=='7'||key=='8'||key=='9'||key=='0'){
           Data[data_count] = key; 
           lcd.setCursor(data_count,0); 
           lcd.print(num); 
           data_count++; 

         }                 
      else if(key=='#'){
           int len;
           len=(sizeof(Data)-1);
           if(len>6){
           data_count=6;
           resetLocker();
           lcd.setCursor(data_count,0); 
           lcd.print(""); 
           data_count++; 
           
           }
      
           }
       }  
       else if(key=='*'){
              clearRow2(7);
           }

 
  // Update the sensor values whenever new data is available

  if ( imu.accelAvailable() )
  {
    // To read from the accelerometer, first call the
    // readAccel() function. When it exits, it'll update the
    // ax, ay, and az variables with the most current data.
    imu.readAccel();
  }


  if ((lastPrint + PRINT_SPEED) < millis())
  {
 
    printAccel(); 





    Serial.println();

    lastPrint = millis(); // Update lastPrint time
  }

   if (intV >=num) {

     digitalWrite(LED1,HIGH);
       } else {

     digitalWrite(LED1,LOW);
               } 

}

void printAccel()
{

   
       float Axy=(imu.calcAccel(imu.ax)-imu.calcAccel(imu.ay));
       long newTime=millis();
       float accelX= imu.calcAccel(imu.ax);
       vX = vX + accelX * (newTime - lastTime)/1000;
       Vkm=vX*3.6;
       intV=Vkm;
       lastTime=newTime;
       //Realvelocity=Vkm;

        Serial.print("A: ");
        #ifdef PRINT_CALCULATED
        // If you want to print calculated values, you can use the
        // calcAccel helper function to convert a raw ADC value to
        // g's. Give the function the value that you want to convert.
        Serial.print(imu.calcAccel(imu.ax), 2);
        Serial.print(", ");
        Serial.print(imu.calcAccel(imu.ay), 2);
        Serial.print(", ");
        Serial.print(Axy, 2);
        Serial.print(" g");
        Serial.print(" ");
        Serial.print("V: ");
       // Serial.print(Vkm, 2);
        #elif defined PRINT_RAW
        Serial.print(imu.ax);
        Serial.print(", ");
        Serial.print(imu.ay);
        Serial.print(", ");
        Serial.print(imu.az);
        #endif     
       
      if(Vkm<0){
         lcd.setCursor(8,1); 
         lcd.print(0);
         Serial.print(0, 2);
        }
      else if(Vkm>=0){
         lcd.setCursor(8,1);
         lcd.print(intV);
         Serial.print(Vkm, 2);
         Serial.print("intV: ");
         Serial.print(intV);
         }        

}

troublerev1.0.ino (4.92 KB)

Take a look at Keypad data entry

This my problem
problem1:
(1) set V> Real v Situation:
set v: 19
Real v: 6

LED: low
(2)set V> Real v Situation:
but

set v: 19
Real v: 9

LED: high

what error for my code?

My goal is
Set v:19
Real v:19

LED :high

picture:1090787.1090788

#include <Wire.h>
#include <SPI.h>
#include <SparkFunLSM9DS1.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

#define KEY_ROWS 4  // 薄膜按鍵的列數
#define KEY_COLS 4  // 薄膜按鍵的行數
#define LCD_ROWS 2  // LCD顯示器的列數
#define LCD_COLS 16 // LCD顯示器的行數
//#define  LED1  5
#define PRINT_CALCULATED
//#define PRINT_RAW
#define PRINT_SPEED 10 // 250 ms between prints

#define DECLINATION -8.58 // Declination (degrees) in Boulder, CO.
LiquidCrystal_I2C lcd(0x27, 16, 2);
LSM9DS1 imu;


// 設置按鍵模組
char keymap[KEY_ROWS][KEY_COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

byte rowPins[KEY_ROWS] = {11, 10, 9, 8};
byte colPins[KEY_COLS] = {7, 6, 5, 4};
Keypad keypad = Keypad(makeKeymap(keymap), rowPins, colPins, KEY_ROWS, KEY_COLS);


static unsigned long lastPrint = 0; // Keep track of print time




//Function definitions
void printGyro();
void printAccel();
void printMag();
void printAttitude(float ax, float ay, float az, float mx, float my, float mz);
void readKeypad();

float Vkm;
float vX=0;
const byte ledPin = 13;
bool acceptKey = true;      // 代表是否接受用戶按鍵輸入的變數,預設為「接受」
bool entryComplete=false;
byte keyAsANumber;
String keywordcomplete,keyword;
char key ;
unsigned int  intV,total=0;
long lastTime=0;
byte digitCount = 7;

void resetLocker() {
  lcd.clear();
  lcd.print("Set V:");
  acceptKey = true;
  keyword = "";
  lcd.setCursor(0, 1);  // 切換到第2行
  lcd.print("Real V:");

}

void readKeypad()
{
 key = keypad.getKey();
 
 if (key >= '0' && key <= '9') //only accept on numeric keys
  {
    keyAsANumber = key - 48;
    total=0;
    total = total * 10;
    total = total+keyAsANumber; //add the new number
    lcd.setCursor(digitCount,0);
    lcd.print(total);
    digitCount++;
  }
  else if (key == '#') //user signals entry is complete
  {
    //lcd.print(key);
    entryComplete = true; //flag completion
    return ; //exit the function
  }
}
void blinkLed() //blink LED using BlinkWithoutDelay principle
//see https://forum.arduino.cc/index.php?topic=503368.0
{
  if (intV >=total)
  {
    digitalWrite(ledPin, HIGH);
  }
  else
    {
    digitalWrite(ledPin,LOW);
    }

  }
void setup()
{
  Serial.begin(115200);

  Wire.begin();

  if (imu.begin() == false) // with no arguments, this uses default addresses (AG:0x6B, M:0x1E) and i2c port (Wire).
  {
    Serial.println("Failed to communicate with LSM9DS1.");
    Serial.println("Double-check wiring.");
    Serial.println("Default settings in this sketch will " \
                   "work for an out of the box LSM9DS1 " \
                   "Breakout, but may need to be modified " \
                   "if the board jumpers are.");
    while (1);
  }
  lcd.begin();       // 初始化lcd物件
  lcd.backlight();  // 開啟背光
  pinMode(ledPin,OUTPUT);
  resetLocker();


  
  
}

void loop()
{

  // Update the sensor values whenever new data is available
  if ( imu.gyroAvailable() )
  {
    // To read from the gyroscope,  first call the
    // readGyro() function. When it exits, it'll update the
    // gx, gy, and gz variables with the most current data.
    imu.readGyro();
  }
  if ( imu.accelAvailable() )
  {
    // To read from the accelerometer, first call the
    // readAccel() function. When it exits, it'll update the
    // ax, ay, and az variables with the most current data.
    imu.readAccel();
  }
  if ( imu.magAvailable() )
  {
    // To read from the magnetometer, first call the
    // readMag() function. When it exits, it'll update the
    // mx, my, and mz variables with the most current data.
    imu.readMag();
  }
  //if(key!=NO_KEY)
  readKeypad();
  if ((lastPrint + PRINT_SPEED) < millis())
  {
    printGyro();  // Print "G: gx, gy, gz"
    printAccel(); // Print "A: ax, ay, az"
    printMag();   // Print "M: mx, my, mz"
    


    // Print the heading and orientation for fun!
    // Call print attitude. The LSM9DS1's mag x and y
    // axes are opposite to the accelerometer, so my, mx are
    // substituted for each other.
    printAttitude(imu.ax, imu.ay, imu.az,
                  -imu.my, -imu.mx, imu.mz);
    Serial.println();

    lastPrint = millis(); // Update lastPrint time
  }
  if(entryComplete==true)
  blinkLed();
        
                        

          
          
  

}
void printGyro()
{
  // Now we can use the gx, gy, and gz variables as we please.
  // Either print them as raw ADC values, or calculated in DPS.
  //Serial.print("G: ");
#ifdef PRINT_CALCULATED
  // If you want to print calculated values, you can use the
  // calcGyro helper function to convert a raw ADC value to
  // DPS. Give the function the value that you want to convert.
  //Serial.print(imu.calcGyro(imu.gx), 2);
  //Serial.print(", ");
  //Serial.print(imu.calcGyro(imu.gy), 2);
  //Serial.print(", ");
  //Serial.print(imu.calcGyro(imu.gz), 2);
  //Serial.println(" deg/s");
#elif defined PRINT_RAW
  //Serial.print(imu.gx);
  //Serial.print(", ");
  //Serial.print(imu.gy);
  //Serial.print(", ");
  //Serial.println(imu.gz);
#endif
}

void printAccel()
{


      
       // Now we can use the ax, ay, and az variables as we please.
       // Either print them as raw ADC values, or calculated in g's.
   
       float Axy=(imu.calcAccel(imu.ax)-imu.calcAccel(imu.ay));
       long newTime=millis();
       float accelX= imu.calcAccel(imu.ax);
       vX = vX + accelX * (newTime - lastTime)/1000;
       Vkm=vX*3.6;
       intV=Vkm;
       lastTime=newTime;
       //Realvelocity=Vkm;

        Serial.print("A: ");
        #ifdef PRINT_CALCULATED
        // If you want to print calculated values, you can use the
        // calcAccel helper function to convert a raw ADC value to
        // g's. Give the function the value that you want to convert.
        Serial.print(imu.calcAccel(imu.ax), 2);
        Serial.print(", ");
        Serial.print(imu.calcAccel(imu.ay), 2);
        Serial.print(", ");
        Serial.print(Axy, 2);
        Serial.print(" g");
        Serial.print(" ");
        Serial.print("V: ");
       // Serial.print(Vkm, 2);
        #elif defined PRINT_RAW
        Serial.print(imu.ax);
        Serial.print(", ");
        Serial.print(imu.ay);
        Serial.print(", ");
        Serial.print(imu.az);
        #endif

         
       
      if(Vkm<0){
         lcd.setCursor(8,1); 
         lcd.print(0);
         Serial.print(0, 2);
        }
      else if(Vkm>=0){
         lcd.setCursor(8,1);
         lcd.print(intV);
         Serial.print(Vkm, 2);
         Serial.print("intV: ");
         Serial.print(intV);
         }

}
 



void printMag()
{
  // Now we can use the mx, my, and mz variables as we please.
  // Either print them as raw ADC values, or calculated in Gauss.
  //Serial.print("M: ");
#ifdef PRINT_CALCULATED
  // If you want to print calculated values, you can use the
  // calcMag helper function to convert a raw ADC value to
  // Gauss. Give the function the value that you want to convert.
  //Serial.print(imu.calcMag(imu.mx), 2);
  //Serial.print(", ");
  //Serial.print(imu.calcMag(imu.my), 2);
  //Serial.print(", ");
  //Serial.print(imu.calcMag(imu.mz), 2);
  //Serial.println(" gauss");
#elif defined PRINT_RAW
  //Serial.print(imu.mx);
  //Serial.print(", ");
  //Serial.print(imu.my);
  //Serial.print(", ");
  //Serial.println(imu.mz);
#endif
}

 //Calculate pitch, roll, and heading.
 //Pitch/roll calculations take from this app note:
 //http://cache.freescale.com/files/sensors/doc/app_note/AN3461.pdf?fpsp=1
 //Heading calculations taken from this app note:
 //http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/Magnetic__Literature_Application_notes-documents/AN203_Compass_Heading_Using_Magnetometers.pdf

problem2:

what wrong to lcd1602 I2c display problem:

if intV:0~9 to 10 ,but not display lcd1602(9,1) 1 display1602(10,1) 0.

picture: 1090823,1090824

void printAccel()
{


      
       // Now we can use the ax, ay, and az variables as we please.
       // Either print them as raw ADC values, or calculated in g's.
   
       float Axy=(imu.calcAccel(imu.ax)-imu.calcAccel(imu.ay));
       long newTime=millis();
       float accelX= imu.calcAccel(imu.ax);
       vX = vX + accelX * (newTime - lastTime)/1000;
       Vkm=vX*3.6;
       intV=Vkm;
       lastTime=newTime;
       //Realvelocity=Vkm;

        Serial.print("A: ");
        #ifdef PRINT_CALCULATED
        // If you want to print calculated values, you can use the
        // calcAccel helper function to convert a raw ADC value to
        // g's. Give the function the value that you want to convert.
        Serial.print(imu.calcAccel(imu.ax), 2);
        Serial.print(", ");
        Serial.print(imu.calcAccel(imu.ay), 2);
        Serial.print(", ");
        Serial.print(Axy, 2);
        Serial.print(" g");
        Serial.print(" ");
        Serial.print("V: ");
       // Serial.print(Vkm, 2);
        #elif defined PRINT_RAW
        Serial.print(imu.ax);
        Serial.print(", ");
        Serial.print(imu.ay);
        Serial.print(", ");
        Serial.print(imu.az);
        #endif

         
       
      if(Vkm<0){
         lcd.setCursor(8,1); 
         lcd.print(0);
         Serial.print(0, 2);
        }
      else if(Vkm>=0){
         lcd.setCursor(8,1);
         lcd.print(intV);
         Serial.print(Vkm, 2);
         Serial.print("intV: ");
         Serial.print(intV);
         }

}

1.png

2.png

try this

#include <Wire.h>
#include <SPI.h>
#include <SparkFunLSM9DS1.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

#define KEY_ROWS 4  // 薄膜按鍵的列數
#define KEY_COLS 4  // 薄膜按鍵的行數
#define LCD_ROWS 2  // LCD顯示器的列數
#define LCD_COLS 16 // LCD顯示器的行數
//#define  LED1  5
#define PRINT_CALCULATED
//#define PRINT_RAW
#define PRINT_SPEED 10 // 250 ms between prints

#define DECLINATION -8.58 // Declination (degrees) in Boulder, CO.
LiquidCrystal_I2C lcd(0x27, 16, 2);
LSM9DS1 imu;


// 設置按鍵模組
char keymap[KEY_ROWS][KEY_COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

byte rowPins[KEY_ROWS] = {11, 10, 9, 8};
byte colPins[KEY_COLS] = {7, 6, 5, 4};
Keypad keypad = Keypad(makeKeymap(keymap), rowPins, colPins, KEY_ROWS, KEY_COLS);


static unsigned long lastPrint = 0; // Keep track of print time

//Function definitions
void printGyro();
void printAccel();
void printMag();
void printAttitude(float ax, float ay, float az, float mx, float my, float mz);
void readKeypad();

float Vkm;
float vX = 0;
const byte ledPin = 13;
bool acceptKey = true;      // 代表是否接受用戶按鍵輸入的變數,預設為「接受」
bool entryComplete = false;
byte keyAsANumber;
String keywordcomplete, keyword;
unsigned int  intV, total = 0;
long lastTime = 0;
byte digitCount = 7;

void resetLocker() {
  lcd.clear();
  lcd.print("Set V:");
  acceptKey = true;
  keyword = "";
  lcd.setCursor(0, 1);  // 切換到第2行
  lcd.print("Real V:");
  total = 0;
  entryComplete = false;
  digitCount = 7;
}

void readKeypad()
{
  char key = keypad.getKey();

  if (key >= '0' && key <= '9') //only accept on numeric keys
  {
    keyAsANumber = key - '0';
    total = total * 10;
    total = total + keyAsANumber; //add the new number
    lcd.setCursor(digitCount, 0);
    lcd.print(keyAsNumber);
    digitCount++;
  }
  else if (key == '#') //user signals entry is complete
  {
    //lcd.print(key);
    entryComplete = true; //flag completion
  }
}


void blinkLed()
{
  if (intV >= total)
  {
    digitalWrite(ledPin, HIGH);
  }
  else
  {
    digitalWrite(ledPin, LOW);
  }
}


void setup()
{
  Serial.begin(115200);
  Wire.begin();

  if (imu.begin() == false) // with no arguments, this uses default addresses (AG:0x6B, M:0x1E) and i2c port (Wire).
  {
    Serial.println("Failed to communicate with LSM9DS1.");
    Serial.println("Double-check wiring.");
    Serial.println("Default settings in this sketch will " \
                   "work for an out of the box LSM9DS1 " \
                   "Breakout, but may need to be modified " \
                   "if the board jumpers are.");
    while (1);
  }
  lcd.begin();       // 初始化lcd物件
  lcd.backlight();  // 開啟背光
  pinMode(ledPin, OUTPUT);
  resetLocker();
}

void loop()
{
  // Update the sensor values whenever new data is available
  if ( imu.gyroAvailable() )
  {
    // To read from the gyroscope,  first call the
    // readGyro() function. When it exits, it'll update the
    // gx, gy, and gz variables with the most current data.
    imu.readGyro();
  }
  if ( imu.accelAvailable() )
  {
    // To read from the accelerometer, first call the
    // readAccel() function. When it exits, it'll update the
    // ax, ay, and az variables with the most current data.
    imu.readAccel();
  }
  if ( imu.magAvailable() )
  {
    // To read from the magnetometer, first call the
    // readMag() function. When it exits, it'll update the
    // mx, my, and mz variables with the most current data.
    imu.readMag();
  }
  //if(key!=NO_KEY)
  readKeypad();
  if ( millis() - lastPrint >= PRINT_SPEED)
  {
    printGyro();  // Print "G: gx, gy, gz"
    printAccel(); // Print "A: ax, ay, az"
    printMag();   // Print "M: mx, my, mz"

    // Print the heading and orientation for fun!
    // Call print attitude. The LSM9DS1's mag x and y
    // axes are opposite to the accelerometer, so my, mx are
    // substituted for each other.
    printAttitude(imu.ax, imu.ay, imu.az, -imu.my, -imu.mx, imu.mz);
    Serial.println();
    lastPrint = millis(); // Update lastPrint time
  }
  if (entryComplete == true)
  {
    blinkLed();
    resetLocker();
  }
}


void printGyro()
{
  // Now we can use the gx, gy, and gz variables as we please.
  // Either print them as raw ADC values, or calculated in DPS.
  //Serial.print("G: ");
#ifdef PRINT_CALCULATED
  // If you want to print calculated values, you can use the
  // calcGyro helper function to convert a raw ADC value to
  // DPS. Give the function the value that you want to convert.
  //Serial.print(imu.calcGyro(imu.gx), 2);
  //Serial.print(", ");
  //Serial.print(imu.calcGyro(imu.gy), 2);
  //Serial.print(", ");
  //Serial.print(imu.calcGyro(imu.gz), 2);
  //Serial.println(" deg/s");
#elif defined PRINT_RAW
  //Serial.print(imu.gx);
  //Serial.print(", ");
  //Serial.print(imu.gy);
  //Serial.print(", ");
  //Serial.println(imu.gz);
#endif
}

void printAccel()
{
  // Now we can use the ax, ay, and az variables as we please.
  // Either print them as raw ADC values, or calculated in g's.

  float Axy = (imu.calcAccel(imu.ax) - imu.calcAccel(imu.ay));
  long newTime = millis();
  float accelX = imu.calcAccel(imu.ax);
  vX = vX + accelX * (newTime - lastTime) / 1000;
  Vkm = vX * 3.6;
  intV = Vkm;
  lastTime = newTime;
  //Realvelocity=Vkm;

  Serial.print("A: ");
#ifdef PRINT_CALCULATED
  // If you want to print calculated values, you can use the
  // calcAccel helper function to convert a raw ADC value to
  // g's. Give the function the value that you want to convert.
  Serial.print(imu.calcAccel(imu.ax), 2);
  Serial.print(", ");
  Serial.print(imu.calcAccel(imu.ay), 2);
  Serial.print(", ");
  Serial.print(Axy, 2);
  Serial.print(" g");
  Serial.print(" ");
  Serial.print("V: ");
  // Serial.print(Vkm, 2);
#elif defined PRINT_RAW
  Serial.print(imu.ax);
  Serial.print(", ");
  Serial.print(imu.ay);
  Serial.print(", ");
  Serial.print(imu.az);
#endif

  if (Vkm < 0) {
    lcd.setCursor(8, 1);
    lcd.print("0       ");
    Serial.print(0.0, 2);
  }
  else if (Vkm >= 0) {
    lcd.setCursor(8, 1);
    lcd.print(intV);
    lcd.print("   ");
    Serial.print(Vkm, 2);
    Serial.print("intV: ");
    Serial.print(intV);
  }
}


void printMag()
{
  // Now we can use the mx, my, and mz variables as we please.
  // Either print them as raw ADC values, or calculated in Gauss.
  //Serial.print("M: ");
#ifdef PRINT_CALCULATED
  // If you want to print calculated values, you can use the
  // calcMag helper function to convert a raw ADC value to
  // Gauss. Give the function the value that you want to convert.
  //Serial.print(imu.calcMag(imu.mx), 2);
  //Serial.print(", ");
  //Serial.print(imu.calcMag(imu.my), 2);
  //Serial.print(", ");
  //Serial.print(imu.calcMag(imu.mz), 2);
  //Serial.println(" gauss");
#elif defined PRINT_RAW
  //Serial.print(imu.mx);
  //Serial.print(", ");
  //Serial.print(imu.my);
  //Serial.print(", ");
  //Serial.println(imu.mz);
#endif
}

thanks blh64:

i try code ,if i touch '#' ,keypad input number disappear.

That is because pressing '#' makes entryComplete = true which ultimately resets the locker.

If that is not the behavior you want, then change the code to do what you want it to do.