📄 main_ex6.c
字号:
#include <REGX51.H>
#define uchar unsigned char
extern void delay(unsigned int i );
ex6()
{
uchar code dispcode[]=
{ 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,
//字形 0 1 2 3 4 5 6 7 8 9
0x88,0x83,0xc6,0xa1,0x86,0x8e,0xff,0xbf,0xff};
//字形 A B C D E F -
//uchar code dispbitcode[]=
// {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff};
// 字位码
unsigned char LED,key,action=1;
LED = 0x01;
while(1)
{
P0 = dispcode[8];
P2 = LED; // LED取反送P1
delay(1500);
P2 |= 0xf0;
key=P2 & 0xf0;
P2 &= 0x0f;
if (key != 0xf0){
if (key == 0xe0) action = 1;
else if (key == 0x70) action = 3;
else action = 2;
}
switch(action)
{
case 1:
if(LED) LED >>=1;
else LED = 0x10;
break;
case 2:
break;
case 3:
if(LED != 0x20) LED <<=1;
else LED = 0x01;
break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -