急求求8×8LED点阵屏仿电梯数字滚动显示单片机C程序
P3端口接点阵
电路图http://hi.baidu.com/m_elvis/album/item/ac7bdc263fc570cdd6cae253.html 展开
// 5*7(2)点阵 pzowen
#include<reg52.h>
#include<absacc.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
/*-------------------------------------------------------
功能:5*7点阵表
----------------------------------------------------------*/
uchar code biao[11][8]=
{
{0x70,0x88,0x98,0xA8,0xC8,0x88,0x70,0x00}, // -0-
{0x20,0x60,0x20,0x20,0x20,0x20,0x70,0x00}, // -1-
{0x70,0x88,0x08,0x30,0x40,0x80,0xF8,0x00}, // -2-
{0xF8,0x08,0x10,0x30,0x08,0x88,0x70,0x00}, // -3-
{0x10,0x30,0x50,0x90,0xF8,0x10,0x10,0x00}, // -4-
{0xF8,0x80,0xF0,0x08,0x08,0x88,0x70,0x00}, // -5-
{0x38,0x40,0x80,0xF0,0x88,0x88,0x70,0x00}, // -6-
{0xF8,0x08,0x10,0x20,0x40,0x40,0x40,0x00}, // -7-
{0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00}, // -8-
{0x70,0x88,0x88,0x78,0x08,0x10,0xE0,0x00}, // -9-
{0x20,0x70,0xa8,0x20,0x20,0x20,0x20,0x00} // -↑-
};
/*-------------------------------------------------------
功能:扫描表
----------------------------------------------------------*/
//uchar code sao[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code sao[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
/*-------------------------------------------------------
功能:串口初始化,波特率9600 方式0 8 UART
-------------------------------------------------------*/
void Init_Com(void)
{
SCON = 0x00; //方式0
}
/*-------------------------------------------------------
功能:延时
-------------------------------------------------------*/
//1
void DELAY_25mS(void)
{
unsigned int x = 45438;
while (--x)
{
_nop_();
}
}
//2
delay(uchar ms)
{ // 延时子程序
uchar i;
while(ms--)
{
for(i = 0; i<250; i++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
//3
delay1(t)
{
while(t--)
{
;
}
}
/*-------------------------------------------------------
功能:显示子程序
-------------------------------------------------------*/
xian()
{
uchar a;
for(a=0;a<8;a++)
{
SBUF =biao[0][a]; //串口发第一个显示字
while(!TI);
TI=0;
SBUF =biao[1][a]; //串口发第二个显示字
while(!TI);
TI=0;
SBUF =biao[3][a]; //串口发第三个显示字
while(!TI);
TI=0;
P1=sao[a]; //
delay1(100);
P1=0xff;
}
}
/*-------------------------------------------------------
主程序
功能:实现接收数据并把接收到的数据发送出去
-------------------------------------------------------*/
void main()
{
uchar ii;
Init_Com();
//SBUF = dis_7[0]; //发送数据
//while(!TI);
//TI=0;
while(1)
{
xian();
}
}