سلام دوستان این برنامه قفل رمزی هست که نوشتم فقط مشکلی در تغییر پسوورد دارم رمز اولیه هم 1234 هست ولی میخوام کاربر رمز رو تغییر بده کمک کنید
#include "main.h"
#include "stm32f4xx_hal.h"
#include "gpio.h"
#include "STM_MY_LCD16X2.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Private variables ---------------------------------------------------------*/
int j=0 ,t1 , b1 , c1 , d1 ;
char a[16];
int data;
int loading;
uint8_t i;
int h;
int pass=1234;
///=====================
int key(void);
//==============================lcd================= ======
#define RS 0
#define E 1
#define D0 0
#define D1 1
#define D2 2
#define D3 3
#define D4 4
#define D5 5
#define D6 6
#define D7 7
//=================================lcd============== =======
void SystemClock_Config(void);
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
////////////////////////////////////////////////
LCD_begin4BIT(GPIOA,RS,E,GPIOB,D4,D5,D6,D7);
LCD_noCursor();
//////////////////////////////////////////////////////
/*
LCD_clear();
for(loading=0;loading<16;loading++)
{
LCD_setCursor(1,1);
LCD_print(" Loading....");
HAL_Delay(10);
LCD_setCursor(2,loading);
LCD_print("\xff");
HAL_Delay(100);
}
LCD_clear();
LCD_setCursor(1,1);
LCD_print(" digital lock "); //lcd
HAL_Delay(300);
LCD_setCursor(2,1);
LCD_print(" version 1.00.0 ");
HAL_Delay(1000);
LCD_clear();
LCD_setCursor(1,1);
LCD_print(" Design By : ");
HAL_Delay(200);
LCD_setCursor(2,1);
LCD_print("alipm...");
HAL_Delay(1000);
LCD_clear();
/////////////////////////////////////////////
*/
j=0;
while (1)
{
///////////////////insert number from user ///////////////////////////
key();
if(j==0 && h)
{
t1=key();
t1=t1*1000;
j=1;
h=0;
}
if(j==1&&h){
b1=key();
b1=b1*100;
j=2;
h=0;
}
if(j==2&&h){
c1=key();
c1=c1*10;
j=3;
h=0;
}
if(j==3&&h){
d1=key();
d1=d1*1;
j=0;
h=0;
}
data=t1+b1+c1+d1;
sprintf(a,"%d",data);
LCD_setCursor(1,1);
LCD_print(a);
LCD_setCursor(2,2);
LCD_print("insert pass");
////////////////// output GPIOB.0 /////////////////
if(data==pass){
LCD_setCursor(2,2);
LCD_print("DOOR OPEN ");
GPIOB->BSRR=(1<<0);
HAL_Delay(1000);
GPIOB->ODR=(1<<16);
data=t1=b1=c1=d1=0;
LCD_clear();
}
}
}
//---------------scan keypad----------------------------
int key(void)
{
GPIOE->ODR=0x01;
HAL_Delay(20);
if(GPIOE->IDR >>4&1){i=1;h=1;}
if(GPIOE->IDR >>5&1){i=2 ;h=1;}
if(GPIOE->IDR >>6&1){i=3 ;h=1;}
if(GPIOE->IDR >>7&1){i=10;h=1;}
GPIOE->ODR=0x02;
HAL_Delay(20);
if(GPIOE->IDR >>4&1) {i=4;h=1;}
if(GPIOE->IDR >>5&1) {i=5;h=1;}
if(GPIOE->IDR >>6&1) {i=6;h=1;}
if(GPIOE->IDR >>7&1) {i=11;h=1;}
GPIOE->ODR=0x04;
HAL_Delay(20);
if(GPIOE->IDR >>4&1) {i=7;h=1;}
if(GPIOE->IDR >>5&1) {i=8;h=1;}
if(GPIOE->IDR >>6&1) {i=9;h=1;}
if(GPIOE->IDR >>7&1) {i=12;h=1;}
GPIOE->ODR=0x08;
HAL_Delay(20);
if(GPIOE->IDR >>4&1) {i=13;h=1;}
if(GPIOE->IDR >>5&1) {i=0;h=1;}
if(GPIOE->IDR >>6&1) {i=14;h=1;}
if(GPIOE->IDR >>7&1) {i=15;h=1;}
return i;
}