找回密码
 注册会员
搜索附件  
MCU资讯论坛 附件中心 单片机论坛 51单片机论坛 5_3_fae60869f2f1c14.gif

5_3_fae60869f2f1c14.gif

 

报名摇摇棒:
前一个星期才知道这个设计比赛,我们三人急忙组了个队参加,因为我们刚上大三,初学单片机,课程比较多,只能每周抽出八九个小时来制作这个,所以做的比较仓促,不过基本功能是都能实现的。不过在这个过程中我们深深感受到了电子设计的趣味性及挑战性。
希望以后多一点这样的学术竞赛,祝电子工程师之家越办越好!


电路图:





软件流程:









eehome.cn





电子工程师之家





中国行




笑脸




心跳





实物





keil c编辑




源程序:

/*================================================*/
/* */
/* 厦门大学电子工程系单片机兴趣小组 */
/* 王雷、文锟、邱传熙 */
/* */
/*================================================*/

#include<reg51.h>

#define uchar unsigned char



//------------两边加0x0000是为了两个字之间延时时不出现字的”拖尾“现象---------
uchar code EE[198] =
{
//--------e----------
0x00,0x00,0x00,0x00,0x00,0xf8,0x01,0xfc,0x01,0x44,0x01,0x44,0x01,0x44,0x01,0xcc,0x00,0xc8,0x00,0x00,0x00,0x00,
//--------e----------
0x00,0x00,0x00,0x00,0x00,0xf8,0x01,0xfc,0x01,0x44,0x01,0x44,0x01,0x44,0x01,0xcc,0x00,0xc8,0x00,0x00,0x00,0x00,
//--------h----------
0x00,0x00,0x10,0x04,0x1f,0xfc,0x1f,0xfc,0x01,0x84,0x01,0x00,0x01,0x04,0x01,0xfc,0x00,0xfc,0x00,0x04,0x00,0x00,
//--------o----------
0x00,0x00,0x00,0x00,0x00,0xf8,0x01,0xfc,0x01,0x04,0x01,0x04,0x01,0x04,0x01,0xf8,0x00,0xf8,0x00,0x00,0x00,0x00,
//--------m----------
0x00,0x00,0x01,0x04,0x01,0xfc,0x01,0xfc,0x01,0x00,0x01,0xfc,0x01,0xfc,0x01,0x00,0x01,0xfc,0x00,0xfc,0x00,0x00,
//--------e----------
0x00,0x00,0x00,0x00,0x00,0xf8,0x01,0xfc,0x01,0x44,0x01,0x44,0x01,0x44,0x01,0xcc,0x00,0xc8,0x00,0x00,0x00,0x00,
//--------.----------
0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//--------c----------
0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xf8,0x01,0x8c,0x01,0x04,0x01,0x04,0x01,0x8c,0x00,0x88,0x00,0x00,0x00,0x00,
//--------n----------
0x00,0x00,0x01,0x04,0x01,0xfc,0x01,0xfc,0x01,0x84,0x01,0x00,0x01,0x04,0x01,0xfc,0x00,0xfc,0x00,0x00,0x00,0x00
};
//------------两边加0x0000是为了两个字之间延时时不出现字的”拖尾“现象---------

uchar code HANZI[252] =
{
//-------电---------
0x00, 0x00,0x00,0x00,0x00,0x00,0x1F,0xF0,0x1F,0xF0,0x12,0x20,0x12,0x20,0x12,0x20,0xFF,0xFC,
0xFF,0xFE,0x12,0x22,0x12,0x22,0x12,0x22,0x1F,0xF2,0x1F,0xF2,0x00,0x0E,0x00,0x0E, 0x00,0x00,
//-------子---------
0x00, 0x00,0x00,0x80,0x00,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x82,0x40,0x83,0x47,0xFF,
0x4F,0xFE,0x58,0x80,0x70,0x80,0x60,0x80,0x40,0x80,0x01,0x80,0x01,0x80,0x00,0x80, 0x00, 0x00,
//-------工---------
0x00, 0x00,0x00,0x04,0x00,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x7F,0xFC,
0x7F,0xFC,0x40,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x00,0x04, 0x00, 0x00,
//-------程---------
0x00, 0x00,0x08,0x20,0x48,0xE0,0x4B,0xC0,0x7F,0xFF,0xFF,0xFF,0x89,0x82,0x89,0xA2,0xFD,0x22,
0xFD,0x22,0x85,0xFE,0x85,0xFE,0x85,0x22,0xFD,0x22,0xFD,0x22,0x01,0x22,0x00,0x02, 0x00, 0x00,
//-------师---------
0x00, 0x00,0x00,0x02,0x3F,0xE6,0x3F,0xEC,0x00,0x78,0xFF,0xF0,0xFF,0x80,0x4F,0xF0,0x4F,0xF0,
0x48,0x00,0x48,0x00,0x7F,0xFF,0x7F,0xFF,0x48,0x20,0x48,0x30,0x4F,0xF0,0x4F,0xE0, 0x00, 0x00,
//-------之---------
0x00, 0x00,0x00,0x04,0x10,0x06,0x10,0x0E,0x10,0x1C,0x10,0x18,0x10,0x3C,0x90,0x24,0xD0,0x64,
0x70,0xC6,0x31,0x82,0x13,0x02,0x16,0x02,0x3C,0x02,0x38,0x02,0x10,0x02,0x00,0x02, 0x00, 0x00,
//-------家---------
0x00, 0x00,0x00,0x00,0x18,0x94,0x38,0x94,0x28,0xBC,0x29,0xA8,0x29,0x7A,0xAB,0xD3,0xEF,0xB3,
0x6D,0xFE,0x28,0xFC,0x29,0xF0,0x29,0x90,0x28,0x98,0x38,0x0C,0x30,0x0C,0x20,0x08,0x00, 0x00
};


//------------两边加0x0000是为了两个字之间延时时不出现字的”拖尾“现象-------

/*------------------小心图-------------------*/
uchar code small_heart[36] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xc0,0x07,0xe0,0x07,0xf0,0x07,0xf0,0x03,0xf8,
0x03,0xf8,0x07,0xf0,0x07,0xf0,0x07,0xe0,0x03,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/*-------------------大心图--------------------*/
uchar code big_heart[36]=
{
0x00,0x00,0x00,0x00,0x0f,0x80,0x1f,0xc0,0x1f,0xe0,0x1f,0xe0,0x1f,0xf0,0x0f,0xf8,0x07,0xfc,
0x07,0xfc,0x0f,0xf8,0x1f,0xf0,0x1f,0xe0,0x1f,0xe0,0x1f,0xc0,0x0f,0x80,0x00,0x00,0x00,0x00
};
/*------------------笑脸图-------------------*/
uchar code smile[36]=
{
0x00,0x00,0x03,0x80,0x0c,0x60,0x10,0x18,0x20,0xc4,0x4c,0x24,0x4c,0x12,0x4c,0x12,0x40,0x12,
0x40,0x12,0x4c,0x12,0x4c,0x12,0x4c,0x24,0x20,0xc4,0x10,0x18,0x0c,0x60,0x03,0x80,0x00,0x00
};

//------------两边加0x0000是为了两个字之间延时时不出现字的”拖尾“现象-------

uchar code CHINA[144] =
{
//-----------中------------
0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xe0,0x3f,0xe0,0x10,0x40,0x10,0x40,0x10,0x40,0xff,0xff,
0xff,0xff,0x10,0x40,0x10,0x40,0x10,0x40,0x3f,0xe0,0x3f,0xe0,0x10,0x00,0x00,0x00,0x00,0x00,
//-----------国------------
0x00,0x00,0x00,0x00,0x7f,0xff,0x7f,0xff,0x50,0x12,0x51,0x12,0x51,0x12,0x51,0x12,0x5f,0xf2,
0x5f,0xf2,0x51,0x92,0x51,0xf2,0x51,0x72,0x50,0x12,0x7f,0xff,0x7f,0xff,0x00,0x00,0x00,0x00,
//-----------行------------
0x00,0x00,0x08,0x40,0x18,0xc0,0x31,0x80,0x63,0xff,0xef,0xff,0xce,0x00,0x46,0x00,0x22,0x00,
0x22,0x02,0x22,0x03,0x23,0xff,0x23,0xfe,0x22,0x00,0x22,0x00,0x22,0x00,0x02,0x00,0x00,0x00,
//-----------!-------------
0x00,0x00,0x00,0x00,0x0f,0xfa,0x0f,0xfa,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
};


uchar wave_time = 0;
uchar state = 10; // 无效状态
uchar flag = 0; // 显示过一遍则置1


//-----延时-------
void delay(uchar time);


void main()
{
signed int i;
IT0 = 1;
IE0 = 0;
EX0 = 1;
EA = 1;

//-----P1接上面八位,P0接下面八位----
P1 = 0xff;
P0 = 0xff;
while(1)
{
//--如果没有中断产生则不显示---
if(!flag)
{
IE0 = 0;//---中断请求置0---
EA = 0;//---关中断----

//----状态转换-------
switch(state)
{
//-------eehome.cn---------
case 0:
{
delay(10); // 使图形在中央附近显示
for(i = sizeof(EE)-1;i >= 0;i--)
{
P1 = ~EE;
P0 = ~EE[--i];
delay(2);
}
flag = 1;
break;
}

//-------电子工程师之家--------
case 1:
{
delay(10); // 使图形在中央附近显示
for(i = sizeof(HANZI)-1;i >= 0;i--)
{
P1 = ~HANZI;
P0 = ~HANZI[--i];
delay(2);
}
flag = 1;
break;
}

//--------中国行!----------
case 2:
{
delay(15); // 使图形在中央附近显示
for(i = sizeof(CHINA)-1;i >= 0;i--)
{
P1 = ~CHINA;
P0 = ~CHINA[--i];
delay(2);
}
flag = 1;
break;
}

//--------笑脸------------
case 3:
{
delay(30); // 使图形在中央附近显示
for(i = sizeof(smile)-1;i >= 0;i--)
{
P1 = ~smile;
P0 = ~smile[--i];
delay(5);
}
flag = 1;
break;
}

//---------心跳(小)----------
case 4:
{
delay(30); // 使图形在中央附近显示
for(i = sizeof(small_heart)-1;i >= 0;i--)
{
P1 = ~small_heart;
P0 = ~small_heart[--i];
delay(5);
}
flag = 1;
break;
}
//---------心跳(大)----------
case 5:
{
delay(30); // 使图形在中央附近显示
for(i = sizeof(big_heart)-1;i >= 0;i--)
{
P1 = ~big_heart;
P0 = ~big_heart[--i];
delay(5);
}
flag = 1;
break;
}

//---------其它不显示----------
default:
{
P1 = 0xff;
P0 = 0xff;
flag = 1;
break;
}
}

EA = 1;//------开中断-------
}
}
}


//-------延时-----------
void delay(uchar time)
{
unsigned int i,j;
for(i = 0;i < 15;i++)
for(j = 0;j < time;j++);
}


//-------外部中断----------
void INT_0() interrupt 0 using 1
{
flag = 0;
if(wave_time++ == 90) wave_time = 0;//-------90次中断一个轮回-------

if(wave_time < 15) state = 0;//-------eehome.cn-------
else if(wave_time < 30) state = 1;//------电子工程师之家-----
else if(wave_time < 45) state = 2;//------中国行!------
else if(wave_time < 60) state = 3;//------笑脸--------
else if(wave_time % 2 == 0) state = 4;//------动画心跳小------
else if(wave_time % 2 == 1) state = 5;//------动画心跳大-------
IE0 = 0;//-------防抖动--------
}








(PS:详情请见附件)

5_3_fae60869f2f1c14.gif

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2025-1-11 04:11 , Processed in 0.041727 second(s), 9 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.