4*4鍵盤結構
if(inter1==1)
{
inter1=0;
show(0xff);
scan(com[x]);
show(seg[n[x]]);
if(x==0)
{
if(HAL_GPIO_ReadPin(row3_GPIO_Port,row3_Pin)==0) key=0;
if(HAL_GPIO_ReadPin(row2_GPIO_Port,row2_Pin)==0) key=1;
if(HAL_GPIO_ReadPin(row1_GPIO_Port,row1_Pin)==0) key=2;
if(HAL_GPIO_ReadPin(row0_GPIO_Port,row0_Pin)==0) key=3;
}
else if(x==1)
{
if(HAL_GPIO_ReadPin(row3_GPIO_Port,row3_Pin)==0) key=4;
if(HAL_GPIO_ReadPin(row2_GPIO_Port,row2_Pin)==0) key=5;
if(HAL_GPIO_ReadPin(row1_GPIO_Port,row1_Pin)==0) key=6;
if(HAL_GPIO_ReadPin(row0_GPIO_Port,row0_Pin)==0) key=7;
}
else if(x==2)
{
if(HAL_GPIO_ReadPin(row3_GPIO_Port,row3_Pin)==0) key=8;
if(HAL_GPIO_ReadPin(row2_GPIO_Port,row2_Pin)==0) key=9;
if(HAL_GPIO_ReadPin(row1_GPIO_Port,row1_Pin)==0) key=10;
if(HAL_GPIO_ReadPin(row0_GPIO_Port,row0_Pin)==0) key=11;
}
else if(x==3)
{
if(HAL_GPIO_ReadPin(row3_GPIO_Port,row3_Pin)==0) key=12;
if(HAL_GPIO_ReadPin(row2_GPIO_Port,row2_Pin)==0) key=13;
if(HAL_GPIO_ReadPin(row1_GPIO_Port,row1_Pin)==0) key=14;
if(HAL_GPIO_ReadPin(row0_GPIO_Port,row0_Pin)==0) key=15;
}
x++;
if(x==4)
{
x=0;
if(ks==0)
{
if(key<16)
{
ks=1;
if(key<10)
{
n[0]=n[1];
n[1]=n[2];
n[2]=n[3];
n[3]=key;
if(n[0]==1 && n[1]==2 && n[2]==3 && n[3]==4)
{
ok=1;
}
else
{
ok=0;
}
}
}
}
if(key==16) ks=0;
key=16;
}
}