Está en la página 1de 11

#includ

e<reg52.h>
code unsigned di
splay[38][5]={
{ 0xc1,0xba,0xb6,0xae,0xc1},

// 0

{ 0xff,0xef,0xdf,0x80,0xff},

// 1

{ 0xb8,0xb6,0xb6,0xb6,0xce},

// 2

{ 0xbd,0xb6,0xa6,0x96,0xb9},

// 3

{ 0xf7,0xe7,0xd7,0x80,0xf7},

// 4

{ 0x8e,0xb6,0xb6,0xb6,0xb9},

// 5

{ 0xc1,0xb6,0xb6,0xb6,0xf9},

// 6

{ 0xbf,0xb8,0xb7,0xaf,0x9f},

// 7

{ 0xc9,0xb6,0xb6,0xb6,0xc9},

// 8

{ 0xcf,0xb6,0xb6,0xb6,0xc1},

// 9

{ 0x5d,0x6b,0x00,0x6b,0x5d},

// star

{ 0x67,0x67,0x00,0x00,0x67},

// hash

{ 0xc0,0xb7,0xb7,0xb7,0xc0},

// A
{ 0x80,0xb6,0xb6,0xb6,0xc9},

{ 0xc1,0xbe,0xbe,0xbe,0xdd},

// C

{ 0x80,0xbe,0xbe,0xdd,0xe3},

// D

{ 0x80,0xb6,0xb6,0xb6,0x7f},

// E

{ 0x80,0xb7,0xb7,0xb7,0xbf},

// F

{ 0xc1,0xbe,0xb6,0xb6,0xd1},

// G

{ 0x80,0xf7,0xf7,0xf7,0x80},

// H

{ 0xff,0xbe,0x80,0xbe,0xff},

// I

{ 0xf9,0xfe,0xfe,0xfe,0x81},

// J

{ 0x80,0xf7,0xeb,0xdd,0xbe},

// K

{ 0x80,0xfe,0xfe,0xfe,0xfe},

// L

{ 0x80,0xdf,0xef,0xdf,0x80},

// M

{ 0x80,0xef,0xf7,0xeb,0x80},

// N

// B

{ 0xc1,0xbe,0xbe,0xbe,0xc1},

// O

{ 0x80,0xb7,0xb7,0xb7,0xcf},
{ 0xc1,0xbe,0xba,0xbd,0xc2},

// Q

{ 0x80,0xb7,0x33,0xb5,0xce},

// R

{ 0xce,0xb6,0xb6,0xb6,0xb9},

// S

{ 0xbf,0xbf,0x80,0xbf,0xbf},

// T

{ 0x81,0xfe,0xfe,0xfe,0x81},

// U

{ 0x83,0xfd,0xfe,0xfd,0x83},

// V

{ 0x80,0xfd,0xfb,0xfd,0x80},

// W

{ 0x9c,0xeb,0xf7,0xeb,0x9c},

// X

{ 0x1f,0xef,0xf0,0xef,0x1f},

// Y

{ 0xbc,0xba,0xb6,0xae,0x9e},

// Z

// P

};

unsigned char keycount=0, keyDetec, repTimer=6;


unsigned char check[12]={0,0,0,0,0,0,0,0,0,0,0,0} ;
void Ms
Delay(unsigned int t);
void Ke
ypad();

void ma
in()
{
Keypa
d();
P3=0x
015;
}

void Ke
ypad()
{
#define
ROW P1

//

COL P2

// for Keypad

#define
unsigne
d char colloc , rowloc; //
unsigne
d char keypad [4][3]={1, 2, 3,
4, 5, 6,
7, 8, 9,
10, 0,11,};
/*
TMOD =0x01 ;

TL0=0XD8;
TH0=0X5E;

TR1=1;

*/

COL =0xFF;
while(1)
{
do
{
ROW =0x00;

//ground all rows

colloc=COL;
colloc &=0x07;
}while(colloc!=0x07); //checking that all keys are relaesed
do
{
do

{
MsDelay(20);
colloc = COL;
colloc &=0x07;

}while(colloc==0x07); //keep checking for keypress


MsDelay(20);
colloc = COL;
colloc &=0x07;

}while(colloc==0x07);//wait for keypress

while(1)
{
ROW =0xFE;

//ground ROW 1

colloc = COL;
colloc &= 0x07;
if(colloc !=0x07)
{
rowloc=0;

//save the row no.

break;
}
ROW =0xFD;

//ground ROW 2

colloc = COL;
colloc &= 0x07;
if(colloc !=0x07)
{
rowloc=1;

//save the row no.

break;
}
ROW =0xFB;

//ground ROW 3

colloc = COL;
colloc &= 0x07;
if(colloc !=0x07)
{
rowloc=2;

//save the row no.

break;
}
ROW =0xF7;

//ground ROW4

colloc = COL;
colloc &= 0x07;
rowloc=3;

//save the row no.

break;
}
keycount++
;
if(collo
c==0x06)
keyDete
c=keypad[rowloc][0];
else if(
colloc==0x05)
keyDete
c=keypad[rowloc][1];
else if(
colloc==0x03)
keyDete
c=keypad[rowloc][2];
P3=keyD
etec;
if(ke
ycount > 0)
check[k

eyDetec]++;
keycou
nt++;
if( check[ke
yDetec]>3 )
check[keyDetec]=0;
break;

}//whil
e1
}//void keypad

void Ms
Delay(unsigned int t)
{
unsigne
d int z1,z2;
for(z1=
0;z1<t;z1++)
for(
z2=0;z2<61;z2++)
;
}

////////////////////////////////////////////////////////////////////////////////
////////////

/*

while(1){

P2=0x01;
P0= display[0][0];
MsDelay(2);

P2=0x02;
P0= display[0][1];
MsDelay(2);
P2=0x04;
P0= display[0][2];
MsDelay(2);

P2=0x08;
P0= display[0][3];
MsDelay(2);
P2=0x10;
P0= display[0][4];
MsDelay(2);

*/

/* if (keyDetec==2 && keycount==1)


{
while(1){

P3=0x01;
P0= display[0][0];

MsDelay(2);

P3=0x02;
P0= display[0][1];
MsDelay(2);
P3=0x04;
P0= display[0][2];
MsDelay(2);

P3=0x08;
P0= display[0][3];
MsDelay(2);
P3=0x10;
P0= display[0][4];
MsDelay(2);
}
}
else if (keyDete
c==2 && keycount==2)
{
while(1){

P3=0x01;
P0= display[1][0];
MsDelay(2);

P3=0x02;
P0= display[1][1];
MsDelay(2);

P3=0x04;
P0= display[1][2];
MsDelay(2);

P3=0x08;
P0= display[1][3];
MsDelay(2);
P3=0x10;
P0= display[1][4];
MsDelay(2);
}
}
else if
(keyDetec==2 && keycount==3)
{
keyc
ount=0;
while(1){

P3=0x01;
P0= display[2][0];
MsDelay(2);

P3=0x02;
P0= display[2][1];
MsDelay(2);
P3=0x04;
P0= display[2][2];
MsDelay(2);

P3=0x08;
P0= display[2][3];
MsDelay(2);
P3=0x10;
P0= display[2][4];
MsDelay(2);
}
}
*/
/* TMOD
=0x11 ;
EA=1;
ET0=1
;
ET1=1
;

TL0=0XD8;
TH0=0X5E;
TL1=0X30;
TH1=0Xf8;

TR0=1;
TR1=1;

while(1);*/
/* //timer1 ISR
void T
0_ISR() interrupt 1
{

repTimer--;
if( repTimer==0)
{
repTimer=6;
Keypad();
}
}
void T1
_ISR() interrupt 3
{

TL1 = 0x30;
TH1 = 0xF8;

}
*/

También podría gustarte