#include <reg51.h>
#include <intrins.h>
unsigned char temp, key, keynum, current_num, end_num, offset, t, x;
void delay(int num)
{
int m, n;
for(m = 0; m < num; m++)
for(n = 0; n < 100; n++)
;
}
unsigned char table[]={
0x00, 0x66, 0x99, 0x81, 0x42, 0x24, 0x18, 0x00,//
0x08, 0x18, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,//1
0x3c, 0x7e, 0x46, 0x0c, 0x18, 0x3e, 0x7e, 0x00,//2
0x3c, 0x66, 0x06, 0x3c, 0x06, 0x66, 0x3c, 0x00,//3
0x0c, 0x1c, 0x3c, 0x6c, 0x7e, 0x7e, 0x0c, 0x00,//4
0x7e, 0x7e, 0x70, 0x7c, 0x06, 0x7e, 0x7e, 0x00,//5
0x3c, 0x7e, 0x60, 0x7c, 0x66, 0x66, 0x3c, 0x00,//6
0x7e, 0x7e, 0x0c, 0x0c, 0x18, 0x18, 0x18, 0x00,//7
0x3c, 0x66, 0x66, 0x3c, 0x66, 0x66, 0x3c, 0x00,//8
0x3c, 0x66, 0x66, 0x3e, 0x06, 0x7e, 0x3c, 0x00};//9
unsigned char key_table[]={
0xee, 0xde, 0xbe, 0x7e,
0xed, 0xdd, 0xbd, 0x7d,
0xeb, 0xdb, 0xbb, 0x7b,
0xe7, 0xd7, 0xb7, 0x77};
void display_t0() interrupt 1
{
int i, j;
TH0 = -4000/256;
TL0 = -4000%256;
P1 = 0xf0;
if (P1 != 0xf0)
{
// delay(100);
// if(P1!= 0xf0)
// {
temp = P1;
P1 = 0x0f;
key = temp|P1;
for(i = 0; i < 16; i++)
{
if(key == key_table[i])
{
keynum = i;
break;
}
}
// }
}
P2 = _crol_(P2 , 1);
j = current_num * 8 + t + offset;
P0 = ~table[j];
if (current_num < keynum)
{
if( ++t == 8)
{
t = 0;
if (++x == 4)
{
x = 0;
if (++offset == 8)
{
offset = 0;
current_num++;
end_num = current_num;
}
}
}
}
else if (current_num > keynum )
{
if( ++t == 8)
{
t = 0;
if (++x == 4)
{
x = 0;
if (--offset == -8)
{
offset = 0;
current_num--;
end_num = current_num;
}
}
}
}
else
{
if( ++t == 8)
t = 0;
}
}
void main()
{
TMOD = 0x01;
TH0 = -4000/256;
TL0 = -4000%256;
TR0 = 1;
ET0 = 1;
EA = 1;
EX0=1;
EX1=1;
IT0=1;
IT1=1;
PX0=1;
P2 = 0x80;
keynum = 1;
current_num = 1;
t = 0;
x = 0;
led = 1;
BEEP = 1;
while(1);
}
uj5u.com熱心網友回復:
首先感謝邀請,抱歉,解釋自己的代碼可以,別人的不懂。uj5u.com熱心網友回復:
給錢就可以解決。uj5u.com熱心網友回復:
P2口是干嘛用的?接的什么硬體?_crol_是干嘛用的?最好寫上一部分注釋或者把完整的代碼和原理圖發出來,不然真的看不懂轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/25621.html
標籤:單片機/工控
上一篇:Hook KdpStub頭部跳轉到KdpTrap,運行就被檢測到,請問怎么弄?
下一篇:求這款板子的資料
