J'ai un tel programme, ça marche. Je reçois le numéro du bouton appuyé sur l'écran LED. Mais j'ai besoin de changer ce programme afin qu'il montre les 2 derniers chiffres pressés sur l'affichage, quand j'appuie sur * ou #. Par exemple, j'appuie sur '1 2 3 4 5 #'. Sur l'affichage, je ne vois que deux derniers chiffres '4 5'. Comment puis-je faire ceci?Microcontrôleur 8051 avec clavier matriciel et affichage à LED
#include <REGX52.h>
#define SEG P1
#define keypad P2
sbit r1 = P2^0;
sbit r2 = P2^1;
sbit r3 = P2^2;
sbit r4 = P2^3;
sbit c1 = P2^4;
sbit c2 = P2^5;
sbit c3 = P2^6;
sbit c4 = P3^7;
void scan(void);
unsigned int Display[12] = {0x0, 0x1, 0x2, 0x3,0x4,0x5,0x6,0x7,0x8,0x9};
void main(void)
{
while(1)
{
scan();
}
}
void scan(void){
r1=0;
r2=r3=r4=1;
if(c1==0)
{
while(c1==0){
P1=Display[1];
}
}
if(c2==0)
{
while(c2==0){
P1=Display[2];
}
}
if(c3==0)
{
while(c3==0){
P1=Display[3];
}
}
r2=0;
r1=r3=r4=1;
if(c1==0)
{
while(c1==0){
P1=Display[4];
}
}
if(c2==0)
{
while(c2==0){
P1=Display[5];
}
}
if(c3==0)
{
while(c3==0){
P1=Display[6];
}
}
r3=0;
r1=r2=r4=1;
if(c1==0)
{
while(c1==0){
P1=Display[7];
}
}
if(c2==0)
{
while(c2==0){
P1=Display[8];
}
}
if(c3==0)
{
while(c3==0){
P1=Display[9];
}
}
r4=0;
r1=r2=r3=1;
if(c2==0)
{
while(c2==0){
P1=Display[0];
}
}