16*24点阵实验程序 #include //包含头文件,一般情况不需要改动,头文件包含特殊功能寄存器的定义
#include
unsigned char segout[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; //8列
unsigned char code tab_a[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//有几列点阵就写几行
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0xF8,0x08,0x08,0x08,0x10,0xF0,0x00,//P的上半部分
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,//C的上半部分
0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,//A的上半部分
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,//X的上半部分
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,//X的上半部分
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,////////////////////////////////////////
0x02,0xE2,0x22,0x22,0x3E,0x80,0x80,0xFF,
0x80,0xA0,0x90,0x88,0x86,0x80,0x80,0x00,//张的上半部分
0x00,0xFE,0x22,0xFE,0x00,0xFE,0x22,0xFE,
0x00,0xFC,0x16,0x25,0x84,0xFC,0x00,0x00,//鹏的上半部分
0x24,0x24,0xA4,0xFE,0x23,0x22,0x00,0x3E,
0x22,0x22,0x22,0x22,0x22,0x3E,0x00,0x00,//程的上半部分
0x80,0x64,0x2C,0x34,0x24,0x24,0xEC,0x32,
0x22,0x22,0x32,0x2E,0x23,0xA2,0x60,0x00,//爱的上半部分
0x10,0x08,0xFC,0xAA,0xAB,0xAA,0xAA,0xFA,
0xAA,0xAA,0xAE,0xA8,0xF8,0x00,0x00,0x00,//鲁的上半部分
0x00,0x00,0x00,0xBE,0x2A,0x2A,0x2A,0xEA,
0x2A,0x2A,0x2A,0x3E,0x00,0x00,0x00,0x00,//星的上半部分
0x00,0x00,0x00,0xBE,0x2A,0x2A,0x2A,0xEA,
0x2A,0x2A,0x2A,0x3E,0x00,0x00,0x00,0x00,//星的上半部分
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,////////////////////////////////////////
0x10,0x08,0xFC,0xAA,0xAB,0xAA,0xAA,0xFA,
0xAA,0xAA,0xAE,0xA8,0xF8,0x00,0x00,0x00,//鲁的上半部分
0x00,0x00,0x00,0xBE,0x2A,0x2A,0x2A,0xEA,
0x2A,0x2A,0x2A,0x3E,0x00,0x00,0x00,0x00,//星的上半部分
0x00,0x00,0x00,0xBE,0x2A,0x2A,0x2A,0xEA,
0x2A,0x2A,0x2A,0x3E,0x00,0x00,0x00,0x00,//星的上半部分
0x80,0x64,0x2C,0x34,0x24,0x24,0xEC,0x32,
0x22,0x22,0x32,0x2E,0x23,0xA2,0x60,0x00,//爱的上半部分
0x02,0xE2,0x22,0x22,0x3E,0x80,0x80,0xFF,
0x80,0xA0,0x90,0x88,0x86,0x80,0x80,0x00,//张的上半部分
0x00,0xFE,0x22,0xFE,0x00,0xFE,0x22,0xFE,
0x00,0xFC,0x16,0x25,0x84,0xFC,0x00,0x00,//鹏的上半部分
0x24,0x24,0xA4,0xFE,0x23,0x22,0x00,0x3E,
0x22,0x22,0x22,0x22,0x22,0x3E,0x00,0x00,//程的上半部分
};
unsigned char code tab_b[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0x02,0x02,0x02,0x01,0x00,0x00,//P的下半部分
0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C的下半部分
0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A的下半部分
0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X的下半部分
0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X的下半部分
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//////////////////////////////////////
0x00,0x43,0x82,0x42,0x3E,0x00,0x00,0xFF,
0x40,0x21,0x06,0x08,0x10,0x20,0x40,0x00,//张的下半部分
0x60,0x1F,0x22,0xBF,0x40,0x3F,0x82,0xFF,
0x00,0x13,0x12,0x12,0x52,0x82,0x7E,0x00,//鹏的下半部分
0x08,0x06,0x01,0xFF,0x01,0x06,0x40,0x49,
0x49,0x49,0x7F,0x49,0x49,0x49,0x41,0x00,//程的下半部分
0x00,0x41,0x21,0x91,0x89,0x87,0x4D,0x55,
0x25,0x25,0x55,0x4D,0x81,0x80,0x80,0x00,//爱的下半部分
0x02,0x02,0x02,0xFA,0xAA,0xAA,0xAA,0xAA,
0xAA,0xAA,0xAA,0xFA,0x02,0x02,0x02,0x00,//鲁的下半部分
0x00,0x44,0x42,0x49,0x49,0x49,0x49,0x7F,
0x49,0x49,0x49,0x49,0x41,0x40,0x00,0x00,//星的下半部分
0x00,0x44,0x42,0x49,0x49,0x49,0x49,0x7F,
0x49,0x49,0x49,0x49,0x41,0x40,0x00,0x00,//星的下半部分
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,///////////////////////////////////////
0x02,0x02,0x02,0xFA,0xAA,0xAA,0xAA,0xAA,
0xAA,0xAA,0xAA,0xFA,0x02,0x02,0x02,0x00,//鲁的下半部分
0x00,0x44,0x42,0x49,0x49,0x49,0x49,0x7F,
0x49,0x49,0x49,0x49,0x41,0x40,0x00,0x00,//星的下半部分
0x00,0x44,0x42,0x49,0x49,0x49,0x49,0x7F,
0x49,0x49,0x49,0x49,0x41,0x40,0x00,0x00,//星的下半部分
0x00,0x41,0x21,0x91,0x89,0x87,0x4D,0x55,
0x25,0x25,0x55,0x4D,0x81,0x80,0x80,0x00,//爱的下半部分
0x00,0x43,0x82,0x42,0x3E,0x00,0x00,0xFF,
0x40,0x21,0x06,0x08,0x10,0x20,0x40,0x00,//张的下半部分
0x60,0x1F,0x22,0xBF,0x40,0x3F,0x82,0xFF,
0x00,0x13,0x12,0x12,0x52,0x82,0x7E,0x00,//鹏的下半部分
0x08,0x06,0x01,0xFF,0x01,0x06,0x40,0x49,
0x49,0x49,0x7F,0x49,0x49,0x49,0x41,0x00,//程的下半部分
};
unsigned char code tab_c[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
/*------------------------------------------------
硬件端口定义
------------------------------------------------*/
***it LATCH = P1^0;
***it SRCLK= P1^2;
***it SER = P1^1;
***it LATCH_B = P2^2;
***it SRCLK_B= P2^0;
***it SER_B= P2^1;
////////////////////////////////////////////////////////////
void DelayUs2x(unsigned char t)
{
while(--t);
}
////////////////////////////////////////////////////////////
void DelayMs(unsigned char t)
{
while(t--)
{
//大致延时1mS
DelayUs2x(245);
DelayUs2x(245);
}
}
///////////////////////////////////////////////////////////////
void SendByte(unsigned char dat)
{
unsigned char i;
for(i=0;i<8;i++)
{
SRCLK=0;
SER=dat&0x80;
dat<<=1;
SRCLK=1;
}
}
/////////////////////////////////////////////////////////////////
void Send2Byte(unsigned char dat1,unsigned char dat2,unsigned char dat3,unsigned char dat4,unsigned char dat5,unsigned char dat6)
{
SendByte(dat1);
SendByte(dat2);
SendByte(dat3);
SendByte(dat4);
SendByte(dat5);
SendByte(dat6);
}
//////////////////////////////////////////////////////////////
void Out595(void)
{
LATCH=0;
_nop_();
LATCH=1;
}
//////////////////////////////////////////////////////////////
void SendSeg(unsigned char dat)
{
unsigned char i;
for(i=0;i<8;i++) //发送字节
{
SRCLK_B=0;
SER_B=dat&0x80;
dat<<=1;
SRCLK_B=1;
}
LATCH_B=0; //锁存
_nop_();
LATCH_B=1;
}
/*------------------------------------------------
主程序
------------------------------------------------*/
void main()
{
unsigned char i,j,k;
while(1)
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
for(j=0;j<2400;j++)//显示长度的控制
for(k=0;k<7;k++)//移动速度
for(i=0;i<8;i++) //8列显示
{
SendSeg(segout[7-i]);
Send2Byte(~tab_a[i+j+16],~tab_a[i+j+8],~tab_a[i+j],~tab_b[i+j+16],~tab_b[i+j+8],~tab_b[i+j]);
Out595();
DelayMs(1);//扫描时间间隔
Send2Byte(0xff,0xff,0xff,0xff,0xff,0xff);//
DelayMs(1); //防止重影
Out595();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
proteus 仿真图如下:
|