#include <reg51.h>
char table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0x80,0x90,0xa0,0x83,0xa7,0xa1,0x84,0x8e};
void main()
{
char scanline;
char displaydata=0xff;
char key;
int col;
P0=0xff;
while(1)
{
scanline=0x01;
for(col=0;col<4;col++)
{
P2=~scanline;
if((P2&0xf0)!=0xf0)
{
key=~(P2&0xf0)>>4;
switch(key)
{
case 0x01:displaydata=col*4+0;break;
case 0x02:displaydata=col*4+1;break;
case 0x04:displaydata=col*4+2;break;
case 0x08:displaydata=col*4+3;break;
}
}
if(displaydata!=0xff)
P0=table[displaydata];
scanline=scanline<<1;
}
}
}
沒有留言:
張貼留言