8×8LED点阵屏显示数字
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
8×8LED点阵屏显示数字的相关程序及电路图:
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar code Table_OF_Digits[]=
{
0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,0x00,
0x00,0x00,0x00,0x21,0x7f,0x01,0x00,0x00,
0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00,
0x00,0x22,0x49,0x49,0x49,0x36,0x00,0x00,
0x00,0x0c,0x14,0x24,0x7f,0x04,0x00,0x00,
0x00,0x72,0x51,0x51,0x51,0x4e,0x00,0x00,
0x00,0x3e,0x49,0x49,0x49,0x26,0x00,0x00,
0x00,0x40,0x40,0x40,0x4f,0x70,0x00,0x00,
0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00,
0x00,0x32,0x49,0x49,0x49,0x3e,0x00,0x00,
};
uchar i=0,t=0,Num_Index = 0; //全局变量延迟时间显示数字//==================================================================//主函数
void main()
{ //主函数开始P3 = 0x80; //扫描最右列
Num_Index = 0; //初始扫描信号
TMOD = 0x00; //定时器方式0
TH0 = (8192-2000)/32; //装入计数初值
TL0 = (8192-2000)%32;
TR0 = 1; //启动定时器T0
IE = 0x82; //允许中断
while(1); //等待中断
}
void LED_Screen_Display() interrupt 1
{
TH0 = (8192-2000)/32; //重装计数初值
TL0 = (8192-2000)%32;
P3 = _crol_(P3,1); //P3口显示左移
P0 = ~Table_OF_Digits[Num_Index * 8 +i]; //从Table_OF_Digits[]中取数
if(++i == 8) //判断i是否为8
i = 0; //若i=8,将i赋值为0
if(++t == 250) //判断时间t是否为250s
{
t = 0x00;
if(++Num_Index == 10) // 判断时间显示数是否为10
Num_Index = 0; // 若为的10,循环显示}
}