#include
#include "74hc595.h"
#define uchar unsigned char
#define uint unsigned int
uchar tab[]={0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff};
uchar code discode[]={
0x10,0x04,0x61,0xFC,0x86,0x03,0x60,0x00,0x08,0x42,0x08,0x81,0xFF,0x7F,0x88,0x40,
0x08,0x30,0xFE,0x0F,0x22,0x00,0x22,0x00,0xE2,0xFF,0x22,0x00,0x22,0x00,0x00,0x00,/*"浙",0*/
0x10,0x04,0x60,0x04,0x01,0x7E,0xC6,0x01,0x30,0x20,0x00,0x20,0x04,0x20,0x04,0x20,
0x04,0x20,0xFC,0x3F,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x00,0x20,0x00,0x00,/*"江",1*/
0x00,0x82,0x02,0x4A,0x02,0x2A,0xE2,0x1E,0xAA,0x4B,0xAA,0x8A,0xAA,0x7A,0xAF,0x02,
0xAA,0x02,0xAA,0x7B,0xAA,0x4A,0xE2,0x4A,0x02,0x7A,0x02,0x02,0x00,0x02,0x00,0x00,/*"嘉",2*/
0x00,0x40,0x82,0x20,0x8C,0x10,0xB8,0x18,0x90,0x0E,0x82,0x04,0x8C,0x00,0xB8,0x00,
0x90,0x00,0x80,0x02,0xC0,0x04,0xB0,0x18,0x9E,0x70,0x84,0x20,0x80,0x00,0x00,0x00,/*"兴",3*/
0x14,0x20,0x24,0x10,0x44,0x4C,0x84,0x43,0x64,0x43,0x1C,0x2C,0x20,0x20,0x18,0x10,
0x0F,0x0C,0xE8,0x03,0x08,0x06,0x08,0x18,0x28,0x30,0x18,0x60,0x08,0x20,0x00,0x00,/*"欢",4*/
0x40,0x40,0x41,0x20,0xCE,0x1F,0x04,0x20,0x00,0x40,0xFC,0x47,0x04,0x42,0x02,0x41,
0x02,0x40,0xFC,0x5F,0x04,0x40,0x04,0x42,0x04,0x44,0xFC,0x43,0x00,0x40,0x00,0x00,/*"迎",5*/
0x80,0x00,0x40,0x20,0x30,0x38,0xFC,0x03,0x03,0x38,0x90,0x40,0x68,0x40,0x06,0x49,
0x04,0x52,0xF4,0x41,0x04,0x40,0x24,0x70,0x44,0x00,0x8C,0x09,0x04,0x30,0x00,0x00,/*"您",6*/
0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x5F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"!",7*/
};
uchar code shuzi[]={
// 0(0) 1(1) 2(2) 3(3) 4(4) 5(5) 6(6) 7(7) 8(8) 9(9)
0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00,/*"0",0*/
0x00,0x00,0x10,0x20,0x10,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/*"1",1*/
0x00,0x00,0x70,0x30,0x08,0x28,0x08,0x24,0x08,0x22,0x88,0x21,0x70,0x30,0x00,0x00,/*"2",2*/
0x00,0x00,0x30,0x18,0x08,0x20,0x88,0x20,0x88,0x20,0x48,0x11,0x30,0x0E,0x00,0x00,/*"3",3*/
0x00,0x00,0x00,0x07,0xC0,0x04,0x20,0x24,0x10,0x24,0xF8,0x3F,0x00,0x24,0x00,0x00,/*"4",4*/
0x00,0x00,0xF8,0x19,0x08,0x21,0x88,0x20,0x88,0x20,0x08,0x11,0x08,0x0E,0x00,0x00,/*"5",5*/
0x00,0x00,0xE0,0x0F,0x10,0x11,0x88,0x20,0x88,0x20,0x18,0x11,0x00,0x0E,0x00,0x00,/*"6",6*/
0x00,0x00,0x38,0x00,0x08,0x00,0x08,0x3F,0xC8,0x00,0x38,0x00,0x08,0x00,0x00,0x00,/*"7",7*/
0x00,0x00,0x70,0x1C,0x88,0x22,0x08,0x21,0x08,0x21,0x88,0x22,0x70,0x1C,0x00,0x00,/*"8",8*/
0x00,0x00,0xE0,0x00,0x10,0x31,0x08,0x22,0x08,0x22,0x10,0x11,0xE0,0x0F,0x00,0x00,/*"9",9*/
};
void delay_ms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void main()
{
uchar i,k;
int j;
while(1)
{
for(i=0;i<16;i++)
{
for(j=3;j>=0;j--) //显示“浙江嘉兴”
{
write_74HC595(discode[j*32+2*i+1]);
write_74HC595(discode[j*32+2*i]);
}
P3=tab[i];
out_74HC595();
}
}
}
#ifndef __74HC595_H__
#define __74HC595_H__
#include
#define uchar unsigned char
#define uint unsigned int
***it DS=P1^0; //串行数据输入端
***it SH_CP=P1^1; //移位寄存器时钟
***it ST_CP=P1^2; //存储寄存器时钟
/*---------------------串行输入,并行输出-------------------------*/
void write_74HC595(uchar dat)
{
/*--------------------串行输入------------------------*/
uchar i;
for(i=0;i<8;i++)
{
SH_CP=0;
DS=dat&0x80;
SH_CP=1; //移位脉冲上升沿
dat=dat<<1;
}
}
/*--------------------并行输出------------------------*/
void out_74HC595()
{
ST_CP=0;
ST_CP=1; //存储脉冲上升沿
ST_CP=0;
}
#endif
|