#include <reg52.h>
#include <intrins.h>
void SendByte(unsigned int);
sbit EN = P3^2; //74HC138使能
sbit RCK = P1^7; //输出存储器锁存时钟线
sbit SI_Ydata = P3^3; //绿灯数据线
sbit SCK = P3^1; //数据输入时钟线
sbit HC595_DR = P1^4; //定义595数据发送口
//A、B、C、D->p2.0~p2.3
unsigned char code font[][32]={
/*---------------成----------------*/
0xFF,0x27,0xFF,0x27,0xC0,0x03,0xC0,0x03,0xCF,0x3F,0xCF,0x3F,0xC1,0x27,0xC1,0x27,
0xC9,0x27,0xC9,0x8F,0xC9,0x9F,0x91,0x19,0x9E,0x49,0x3C,0xE1,0xBD,0xF3,0xFF,0xFF,
/*---------------功----------------*/
0xFF,0x3F,0xFF,0x3F,0x03,0x3F,0x03,0x3F,0xCC,0x03,0xCC,0x03,0xCF,0x33,0xCF,0x33,
0xCF,0x33,0xCF,0x33,0xC2,0x73,0x02,0x73,0x1C,0xF3,0xF1,0xC3,0xFB,0xC7,0xFF,0xFF,
/*---------------点----------------*/
0xFC,0xFF,0xFC,0xFF,0xFC,0x03,0xFC,0x03,0xFC,0xFF,0xC0,0x07,0xC0,0x07,0xCF,0xE7,
0xCF,0xE7,0xC0,0x07,0xC0,0x07,0xFF,0xFF,0xD9,0x33,0x99,0x99,0x39,0x99,0xFF,0xFF,
/*---------------亮----------------*/
0xFC,0xFF,0x80,0x03,0x80,0x03,0xFF,0xFF,0xE0,0x0F,0xE7,0xCF,0xE0,0x0F,0xFF,0xFF,
0x00,0x03,0x3F,0xF3,0xF0,0x3F,0xF3,0x3F,0xF3,0x3B,0xE7,0x03,0x8F,0x83,0xFF,0xFF,
};
unsigned char code love[][32]={
{0xFF,0xFD,0xB2,0x96,0xA6,0xB6,0x90,0xA6,0x36,0x76,0x66,0x16,0x76,0xF6,0xF3,0xFF},
{0xFD,0xFB,0xFA,0xF6,0xCD,0x1D,0xAB,0xAB,0xB7,0xA7,0x9B,0xBB,0xFD,0xFC,0xFD,0xFF},/*"爱",0*/
{0xFB,0xFB,0xBB,0xBB,0x80,0x7B,0x7B,0xFB,0xFB,0x00,0xFB,0xBB,0xCA,0xFB,0xFB,0xFF},
{0xDF,0xDF,0xBD,0xBE,0x01,0x7F,0x7F,0xF7,0xF7,0xEF,0x1F,0xA7,0x7B,0xFD,0xF0,0xFF},/*"我",1*/
};
main(void)
{
unsigned char i,j;
EN=0;
while(1)
{
P1=0xff;
for(i=0;i<16;i++)
{
for(j=0;j<4;j++)
{
SendByte(font[j][i*2]);
SendByte(font[j][i*2+1]);
// SendByte(love[j][i*2]);
// SendByte(love[j][i*2+1]);
}
RCK=0;
RCK=1;
P1=i;
// HC595_DR=1;
}
}
}
void SendByte(unsigned int dat) //传1BYTE函数
{
unsigned char i;
for(i=0;i<8;i++)
{
// SI_Ydata = (bit)(dat&0x80);
HC595_DR = (bit)(dat&0x80);
SCK=0;
SCK=1;
dat <<= 1;
}
}
|