olá, estou recém aprendendo c, recebi um código praticamente pronto, faltando apenas configurar um teclado matricial, vou botar o que já tenho aqui que consegui com ajuda, o que eu queria era fazer uma sequencia das teclas, por exemplo, eu aperto o 1, ele leva ao display o 1, quando clico outra tecla ele somente substitui no display, porém gostaria de escrever ''132" por exemplo, se alguém puder me ajudar agradeço.
void teclado_matricial(void)
{
port_b_dir.bit_2=input;
port_b_dir.bit_3=input;
port_b_dir.bit_4=input;
port_b_dir.bit_5=input;
port_e_dir.bit_6=output;
port_e_out.bit_6=0;
port_e_dir.bit_7=input;
port_b_dir.bit_0=input;
port_b_dir.bit_1=input;
delay_us(100);
if (port_b_in.bit_2==0) key_virgula=1;
else key_virgula=0;
if (port_b_in.bit_3==0) key_7=1;
else key_7=0;
if (port_b_in.bit_4==0) key_4=1;
else key_4=0;
if (port_b_in.bit_5==0) key_1=1;
else key_1=0;
port_e_dir.bit_7=output;
port_e_out.bit_7=0;
port_e_dir.bit_6=input;
delay_us(100);
if (port_b_in.bit_2==0) key_zero=1;
else key_zero=0;
if (port_b_in.bit_3==0) key_8=1;
else key_8=0;
if (port_b_in.bit_4==0) key_5=1;
else key_5=0;
if (port_b_in.bit_5==0) key_2=1;
else key_2=0;
port_b_dir.bit_0=output;
port_b_out.bit_0=0;
port_e_dir.bit_7=input;
delay_us(100);
if (port_b_in.bit_2==0) key_10k=1;
else key_10k=0;
if (port_b_in.bit_3==0) key_9=1;
else key_9=0;
if (port_b_in.bit_4==0) key_6=1;
else key_6=0;
if (port_b_in.bit_5==0) key_3=1;
else key_3=0;
port_b_dir.bit_1=output;
port_b_out.bit_1=0;
port_b_dir.bit_0=input;
delay_us(100);
if (port_b_in.bit_2==0) key_30k=1;
else key_30k=0;
if (port_b_in.bit_3==0) key_milhao=1;
else key_milhao=0;
if (port_b_in.bit_4==0) key_k=1;
else key_k=0;
if (port_b_in.bit_5==0) key_r=1;
else key_r=0;
}
lcd_write("\r resistencia: \n ");
lcd_write_value(1,resistencia);
lcd_write(" ohms ");
e_resistor(resistencia);
if (key_1) resistencia=1;
if (key_2) resistencia=2;
if (key_3) resistencia=3;
if (key_4) resistencia=4;
if (key_5) resistencia=5;
if (key_6) resistencia=6;
if (key_7) resistencia=7;
if (key_8) resistencia=8;
if (key_9) resistencia=9;