一下是完整代码:
******************************************************************/
//包含头文件
#include <reg52.h>
#include "74HC595.H"
/*--------------------------------------------------------------*/
//全局变量定义
unsigned char i;
unsigned int m,n;
/*--------------------------------------------------------------*/
//代码库
#define num sizeof(table) //代码长度
unsigned char code aa[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code table[]= {
//取模方式 阴码 列扫描 逆向
0x0,0x88,0x49,0x29,0x1F,0x29,0x49,0x88, //显示“天”字,取模方式为:逐字取模 , C51十六进制 */
0x0,0x88,0x49,0x29,0x1F,0x29,0x49,0x88, //显示“天”字,取模方式为:逐字取模 , C51十六进制 */
0xFC,0x6,0x75,0x54,0x54,0x74,0x84,0xFC, //显示“向”字,取模方式为:逐字取模 , C51十六进制 */
0x80,0x80,0x80,0xFF,0x88,0x88,0x80,0x80, //显示“上”字,取模方式为:逐字取模 , C51十六进制 */
};
/*--------------------------------------------------------------*/
//显示函数
void Display(void)
{
Ser_IN((aa[i])); //列扫描数据
Ser_IN(table[i + n]); //查表取出行扫描数据
Par_OUT(); //输出显示
i++; if(i == 8) i = 0; //循环扫描
m++; if(m == 800) {m = 0; n++;} //滚动速度控制
if(n == num-7) n = 0; //循环显示
}
/*--------------------------------------------------------------*/
//定时器初始化
void T0_init(void)
{
TMOD = 0xf8;
TH0 = 0xcc; //5000us
TL0 = 0x00;
IE = 0x82;
TR0 = 1;
}
/*--------------------------------------------------------------*/
//定时器中断服务
void T0_intservice(void) interrupt 1 using 0
{
TH0 = 0xf8;
TL0 = 0xcc;
Display();
}
/*--------------------------------------------------------------*/
//主函数
void main (void)
{
T0_init();
while(1);
}
******************************************************************/
//包含头文件
#include <reg52.h>
#include "74HC595.H"
/*--------------------------------------------------------------*/
//全局变量定义
unsigned char i;
unsigned int m,n;
/*--------------------------------------------------------------*/
//代码库
#define num sizeof(table) //代码长度
unsigned char code aa[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code table[]= {
//取模方式 阴码 列扫描 逆向
0x0,0x88,0x49,0x29,0x1F,0x29,0x49,0x88, //显示“天”字,取模方式为:逐字取模 , C51十六进制 */
0x0,0x88,0x49,0x29,0x1F,0x29,0x49,0x88, //显示“天”字,取模方式为:逐字取模 , C51十六进制 */
0xFC,0x6,0x75,0x54,0x54,0x74,0x84,0xFC, //显示“向”字,取模方式为:逐字取模 , C51十六进制 */
0x80,0x80,0x80,0xFF,0x88,0x88,0x80,0x80, //显示“上”字,取模方式为:逐字取模 , C51十六进制 */
};
/*--------------------------------------------------------------*/
//显示函数
void Display(void)
{
Ser_IN((aa[i])); //列扫描数据
Ser_IN(table[i + n]); //查表取出行扫描数据
Par_OUT(); //输出显示
i++; if(i == 8) i = 0; //循环扫描
m++; if(m == 800) {m = 0; n++;} //滚动速度控制
if(n == num-7) n = 0; //循环显示
}
/*--------------------------------------------------------------*/
//定时器初始化
void T0_init(void)
{
TMOD = 0xf8;
TH0 = 0xcc; //5000us
TL0 = 0x00;
IE = 0x82;
TR0 = 1;
}
/*--------------------------------------------------------------*/
//定时器中断服务
void T0_intservice(void) interrupt 1 using 0
{
TH0 = 0xf8;
TL0 = 0xcc;
Display();
}
/*--------------------------------------------------------------*/
//主函数
void main (void)
{
T0_init();
while(1);
}