51单片机驱动16*16点阵显示生日快乐程序
妞都狠喜欢这个了,显示生日快乐4个字然后还有心型,还有i love you,全部源码和仿真文件的下载地址是:http://www.51hei.com/bbs/dpj-18851-1.html
下面是部分源码预览:
#include
#include
#define din P3_2
#define load P3_3
#define clk P3_4
#define uchar unsigned char
#define uint unsigned int
unsigned char code dispcode[]={0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70,0x7f,0x7b,0x01};
uchar buf[]={0,0,0,0,0,0,0,0};
SYSTEMTIME time1;
unsigned char code tab1[]={
0x0F,0x00,0x1F,0x80,0x3F,0xC0,0x7F,0xE0,
0x7F,0xF0,0x7F,0xF8,0x3F,0xFC,0x1F,0xFE,
0x1F,0xFE,0x3F,0xFC,0x7F,0xF8,0x7F,0xF0,
0x7F,0xE0,0x3F,0xC0,0x1F,0x80,0x0F,0x00,//心型图
0x00,0x80,0x01,0x02,0x06,0x02,0x78,0x82,
0x08,0x82,0x08,0x82,0x08,0x82,0x08,0x82,
0xFF,0xFE,0x48,0x82,0x08,0x82,0x08,0x82,
0x19,0x82,0x08,0x86,0x00,0x02,0x00,0x00,/*"生",2*/
0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFC,
0x42,0x08,0x42,0x08,0x42,0x08,0x42,0x08,
0x42,0x08,0x42,0x08,0x42,0x08,0x7F,0xFC,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"日",3*/
0x0E,0x00,0x00,0x00,0xFF,0xFF,0x10,0x00,
0x0D,0x01,0x11,0x02,0x11,0x0C,0x11,0x70,
0xFF,0x80,0x11,0x60,0x11,0x10,0x11,0x0C,
0x1F,0x06,0x01,0x03,0x01,0x02,0x00,0x00,/*"快",4*/
0x00,0x00,0x00,0x04,0x02,0x18,0x3F,0x30,
0x22,0xE0,0x22,0x48,0x22,0x04,0x62,0x02,
0x5F,0xFC,0x42,0x00,0xC2,0x00,0xC2,0x40,
0x42,0x30,0x02,0x1C,0x00,0x08,0x00,0x00,/*"乐",5*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x3F,0x8C,0x7F,0xDE,
0x7F,0xDE,0x3F,0x8C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//!
0x00,0x00,0x42,0xFE,0x42,0x02,0x7E,0x00,
0x42,0xFE,0x42,0x82,0x00,0xFE,0x00,0x00,
0x00,0xFC,0x00,0x02,0x7E,0xFC,0x02,0x00,
0x02,0xFE,0x02,0x92,0x7E,0x92,0x00,0x00,//I LOVE U
0xE0,0x07,0x8F,0xF1,0x98,0x19,0x30,0x0C,
0x64,0x46,0x48,0x22,0x44,0x12,0x40,0x12,
0x40,0x12,0x44,0x12,0x48,0x22,0x64,0x46,
0x30,0x0C,0x98,0x19,0x8F,0xF1,0xE0,0x07,//笑脸
};
unsigned char code tab2[]={ 0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,
0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00};
uchar code tab3[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x03,0x06,
0x0c,0x18,0x30,0x60,0xe0,0x70,0x38,0x1c,0x0e,0x07,
0x0f,0x1f,0x3e,0x7c,0xf8,0xfc,0x7e,0x3f,0x7f,0xfe,
0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0x3f,
0x9f,0xcf,0xe7,0xf3,0xf9,0xfc,0xf8,0xf1,0xe3,0xc7,
0x8f,0x1f,0x0f,0x87,0xc3,0xe1,0xf0,0xe0,0xc1,0x83,
0x07,0x03,0x81,0xc0,0x80,0x01,0x00,
0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00,0x01,0x03,
0x07,0x0f,0x1f,0x3f,0x7f,0xff,0xe7,0xc3,0x81,0x00,
0x81,0xc3,0xe7,0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,
0xbf,0x7f,0x7e,0x7d,0x7b,0x77,0x6f,0x5f,0x3f,0x3e,
0x3d,0x3b,0x37,0x2f,0x1f,0x1e,0x1d,0x1b,0x17,0x0f,
0x0e,0x0d,0x0b,0x07,0x06,0x05,0x03,0x02,0x01,0x00,
0x55,0xaa,0x55,0xaa,0x00,0xff,0x00,0xff,0x00,0xff,};
sbit KAI=P1^4;
sbit KAI2=P1^5;
void delay(uint time);
uint j=0,q=0;
uchar r,t=0,num=0;
void csh()
{
load=1;
clk=1;
din=1;
}
Delayms(uint c)
{
uint a,b;
for(a=0;a
}
void write(uchar com,uchar da)
{
uchar temp,i,j;
load=0;
clk=0;
for(i=0;i<8;i++)
{ temp=com;
if((temp&(0x80>>i))!=0)
din=1;
else din=0;
clk=1;
for(j=0;j<5;j++);
clk=0;
}
for(i=0;i<8;i++)
{ temp=da;
if((temp&(0x80>>i))!=0)
din=1;
else din=0;
clk=1;
for(j=0;j<5;j++);
clk=0;
}
load=1;
}
void main()
{
csh();
write(0x0c,0x01);//正常工作状态,关断模式
write(0x09,0x00);//译码选择,非BCD码
write(0x0a,0x0a);//亮度调节
write(0x0b,0x07);//显示位数
Initial_DS1302();
while(1)
{
DS1302_GetTime(&time1);
buf[7]=(time1.Second)%10;
buf[6]=(time1.Second)/10;
buf[4]=(time1.Minute)%10;
buf[3]=(time1.Minute)/10;
buf[1]=(time1.Hour)%10;
buf[0]=(time1.Hour)/10;
write(0x08,dispcode[buf[7]]);
write(0x07,dispcode[buf[6]]);
write(0x06,dispcode[10]);
write(0x05,dispcode[buf[4]]);
write(0x04,dispcode[buf[3]]);
write(0x03,dispcode[10]);
write(0x02,dispcode[buf[1]]);
write(0x01,dispcode[buf[0]]);
// Delayms(200);
num++;
if(num==137)
num=0;
for(r=0;r<105;r++)
for(j=q;j<32+q;j++)
{
P1=tab2[t];
KAI=1;
P2=0X00;
P2=tab1[j];
KAI=0;
j++;
KAI2=1;
P2=0X00;
P2=tab1[j];
KAI2=0;
P0=tab3[num];
delay(40);
t++;
if(t==16)
t=0;
}
q=q+32;
if(q==256)
q=0;
}
}
void delay(uint time)
{
uint linger;
for(linger=0;linger}
51单片机16*16点阵生日快乐程 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)