#include<reg51.h>
#include<intrins.h>
typedef unsigned char u8;
typedef unsigned int u16;
void delay(u16 i)
{
while(i--);
}
u8 code ledwei[]=
{
0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,
};
sbit SER = P3^4; //串行数据输入
sbit RCLK = P3^5; //存储寄存器时钟输入
sbit SRCLK = P3^6; //移位寄存器时钟输入
u8 code Digital1[]=
{
/*-- 文字: 普 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x44,0x54,0x64,0x45,0x7E,0x44,0x44,0x44,0x7E,0x45,0x64,0x54,0x44,0x40,0x00,
0x00,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0x49,0x49,0xFF,0x00,0x00,0x00,0x00,
};
u8 code Digital2[]=
{
/*-- 文字: 我 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x20,0x24,0x24,0x24,0xFE,0x23,0x22,0x20,0x20,0xFF,0x20,0x22,0x2C,0xA0,0x20,0x00,
0x00,0x08,0x48,0x84,0x7F,0x02,0x41,0x40,0x20,0x13,0x0C,0x14,0x22,0x41,0xF8,0x00,
};
void HC595(u8 dat1,u8 dat2, u8 dat3, u8 dat4)
{
u8 a;
for(a=0; a<8; a++)
{
SER = dat1 >>7;
dat1 <<= 1;
SRCLK = 0;
_nop_();
_nop_();
SRCLK = 1;
_nop_();
_nop_();
}
for(a=0; a<8; a++)
{
SER = dat2 >>7;
dat2 <<= 1;
SRCLK = 0;
_nop_();
_nop_();
SRCLK = 1;
_nop_();
_nop_();
}
for(a=0; a<8; a++)
{
SER = dat3 >>7;
dat3 <<= 1;
SRCLK = 0;
_nop_();
_nop_();
SRCLK = 1;
_nop_();
_nop_();
}
for(a=0; a<8; a++)
{
SER = dat4 >>7;
dat4 <<= 1;
SRCLK = 0;
_nop_();
_nop_();
SRCLK = 1;
_nop_();
_nop_();
}
RCLK = 0;
_nop_();
_nop_();
RCLK = 1;
_nop_();
_nop_();
}
void main()
{
u8 i ;
while(1)
{
for(i=0;i<16;i++)
{
HC595(~ledwei[i+16],~ledwei[i],Digital2[16+i],Digital2[i]);
delay(10);
}
}
}
|