Home > other >  To be able to complete the keyboard let go
To be able to complete the keyboard let go

Time:09-19

# include
# define uchar signed char
# define uint signed int
Uchar code table []={
X5b x3f 0, 0 x06, 0, 0 x4f,
X6d 0 x66, 0, 0 x7d, 0 x07,
X6f 0 x7f, 0, 0 x77, 0 x7c,
X5e 0 x39, 0, 0 x79, 0 x71,
X38 x76 0, 0 x79, 0, 0 x3f, 0};
Uchar temp, num;
Sbit dule=P2 ^ 6;
Sbit wale=P2 ^ 7;
Void the display (uchar);
Void delay (uint z);
Uchar keyscan ();
Void init ();
Void main ()
{
init();
While (1)
{
The display (keyscan ());
}
}
Void init ()
{
Num=0;
Dule=1;
P0=0 x3f;
Dule=0;
Wale=1;
P0=0 x00;
Wale=0;
}
Uchar keyscan ()
{
P3=0 xfe;
Temp=P3;
Temp=temp & amp; 0 xf0;
If (temp!=0 xf0)
{
Delay (5);
Temp=P3;
Temp=temp & amp; 0 xf0;
If (temp!=0 xf0)
{
Temp=P3;
The switch (temp)
{
Case 0 xee: num=1;
break;
Case 0 xde: num=2;
break;
Case 0 xbe: num=3;
break;
Case 0 x7e: num=4;
break;
}
while(temp !=0 xf0)
{
Temp=P3;
Temp=temp & amp; 0 xf0;
}
}
}
Return (num);
}
Void the display (uchar num)
{
Dule=1;
P0=table (num);
Dule=0;
P0=0 XFF;
Wale=1;
P0=0 x00;
Wale=0;
}
Void delay (uint z)
{
Uint x, y;
For (x=z; X> 0; X -)
For (y=110; Y> 0; Y -);
}
I can't finish this program to let go to detect

CodePudding user response:

To join https://blog.csdn.net/xianfajushi/article/details/80884859? Ops_request_misc=% 7 b % 22 request % 5 fid % 3 a 22% 22% % 22158296947219724845017776% 2 c % 22 SCM % 22% % 2220140713.130056874. 3 a. % 22% 7 d & amp; Request_id=158296947219724845017776 & amp; Biz_id=0 & amp; Utm_source=distribute. Pc_search_result. None - a task

CodePudding user response:

Keyscan (), the display (uchar num) changed:
# include
# define uchar signed char
# define uint signed int
Uchar code table []={
X5b x3f 0, 0 x06, 0, 0 x4f,
X6d 0 x66, 0, 0 x7d, 0 x07,
X6f 0 x7f, 0, 0 x77, 0 x7c,
X5e 0 x39, 0, 0 x79, 0 x71,
X38 x76 0, 0 x79, 0, 0 x3f, 0};
Uchar temp, num;
Sbit dule=P2 ^ 6;
Sbit wale=P2 ^ 7;
Void the display (uchar);
Void delay (uint z);
Uchar keyscan ();
Void init ();
Void main ()
{
init();
While (1)
{
Uchar key;
Key=keyscan ();
The display (key);

}
}
Void init ()
{
Num=0;
Dule=1;
P0=0 x3f;
Dule=0;
Wale=1;
P0=0 x00;
Wale=0;
}
Uchar keyscan ()
{
P3=0 xfe;

While (1)
{
Temp=P3;
The switch (temp)
{
Case 0 xee: num=1;//0 xee
break;
Case 0 xde: num=2;//0 xde
break;
Case 0 xbe: num=3;//0 xbe
break;
Case 0 x7e: num=4;//0 x7e
break;

}

Return (num);
}

}
Void the display (uchar num)
{

P0=table (num);
Dule=1;
Delay (1);
Dule=0;

/* P0=0 x00;
Wale=1;
Delay (1);
Wale=0; */
//P0=0 x00;
//P0=0 XFF;
}
Void delay (uint z)
{
Uint x, y;
For (x=z; X> 0; X -)
For (y=110; Y> 0; Y -);
}
  • Related