` 本帖最后由 吴鉴鹰 于 2015-4-23 10:12 编辑
2、吴鉴鹰单片机项目详细解析系列(连载)之基于单片机的摇摇棒制作
QQ群1号:332164870【1000人群】(已满) 群内已有成员1000余人!欢迎大家加入学习,交流,咨询!三者加一即可!
HI!大家好,我叫吴鉴鹰,100%年中国制造,长181cm,净重70kg。采用人工智能,各部分零件齐全,软硬件运转稳定,经二十多年的运行,属质量信得过产品。是一名从业两年的单片机工程师,长年从事单片机、DSP、FPGA以及触摸屏的项目开发,自信比牛顿更懂单片机、比诸葛亮更会玩DSP、比汉武大帝懂得社么是指针,这年头就得玩一个综合实力。
其实吧, 人还不错,出了长点帅点以外,也没什么缺点。
在校期间,曾参加学校组织的电子设计大赛,一不小心获得了一等奖,于是代表学校参加全省的电子设计大赛,一不小心碰上强敌,虽获得一等奖,但并未拿到当年的最高奖项,所见,人外有人,天外有天于是更加发奋学习,以图他日能技艺超群,闻得德赢Vwin官网
有一大帮志同道合之士,愿意一同切磋武艺,于是花以时日浏览之,果然不泛有卧虎藏龙之辈,吴某深感钦佩。 从大学二年级起,尾随恩师混迹于各大实验室,也算小有技术心得,现在愿意与大家一块分享两年的项目经验,我相信只有交流才能促进发展,只有讨论才能提升能力,恳请各位前辈同行斧正。
现在来第二讲,详细解析如何制作基于单片机的摇摇棒,提供详细的硬件原理图和软件程序。
何为摇摇棒,鹰哥老给你们介绍摇摇棒是如今流行的一种玩具,在各种聚会、节日中均见得到它的身影。本设计也追随着摇摇棒的原理,利用人眼的视觉暂留特性,通过AT89S52单片机对16只高亮度LED发光二极管进行控制, 配合手的左右摇晃就可呈现一幅完整的画面。 有需要下载原理图的请点击下载: 鹰哥的摇摇棒具有如下功能: 1) 显示 “就要离开我最爱的大学了!”; 2) 显示 “o(∩_∩)o”微笑图案; 3) 显示 心形图案; 4) 显示 “LOVE”; 5) 显示 “天天开心” 6)显示 “笑笑照顾好自己!” 7)显示 “我们毕业了!” 8)显示 “周晓晓” 9) 可以通过开关实现转换,轮流显示并循环。
跟大家讲,摇摇棒其实很简单,大学期间,我自己用万用板搭了一个,别人觉得很好玩,就来问我怎么做。其实就是一个循环的LED显示,利用人的视觉滞留产生静态显示的现象。要实现这个目标,就要求延时部分做的比较小,所以采用石英晶体振荡器。而目前能够实现这种功能的器件有很多种,不同的类型的器件也能够很好的完成。
鹰哥的这个作品本着方便、价格低廉的原则,采用单片机控制,由水银开关的闭合对单片机产生外部中断,从而对中断进行采集。到达一定数量便进行图象的转换。
这是鹰哥当年在大学做的送给女朋友的哦!她玩了好久,还带回去给她老爸看了,所以年轻的工程师可以做一个送给你心爱的姑娘啊!信鹰哥,搞定女神不是梦!
整个系统由单片机控制模块,开关及 电源模块和输出显示模块三个部分构成。
硬件原理图,点击下载:
2、主要部件原理 (1)单片机控制模块 用单片机想要控制LED显示只需要定时输出就可以,但每个人摇动的速度不一样,如何准确的并稳定的变换图案呢?这就需要用到外部中断。将水银开关的两个引脚一端接VCC,一端接GND,这样的话,当摇棒向一边运动时LED按照程序编辑好的规律显示,而向另一边运动时LED全灭,此时一个周期就会产生一个下跳沿的信号,信号传递给单片机的nINT0产生中断,对中断的数量计数,当计到10时便转换显示的图案,当依次显示完后便回到初始状态进行循环。 由于人的视觉滞留时间长达0.1s,所以在每显示完一列LED后加入一段合适的延时,如5ms,每个字之间加入延时如15ms,这样,我们就能看到静态的稳定的字,并且每个字之间是有空隙的。为了让字能够在空间的中部显示,在启动中断显示后延时一段合适的时间,使棒在半圆轨迹的大约1/4处开始显示,这样看到的字方向上才比较正。 (2)水银开关 水银开关,又称倾侧开关,是电路开关的一种,以一接著电极的小巧容器储存著一小滴水银,容器中多数注入惰性气体或真空。 仔细观察水银开关,实际上他是一个封闭的玻璃管,里面有两个分开着的导线和一段水银球,当玻璃管的平衡位置变化时,水银球会来回移动,当水银球移动到两根导线时,因水银是金属-导体,故电路变为通路,此时接收器处于工作状态;反之,水银球远离两根导线时为断路,此时接收器处于非工作状态。 本设计采用震动开关代替水银开关,试验测试发现,水银开关多次高频率的接通断开后触点会氧化,容易接触不良,因此改用下面的震动开关。
主要的人原理和器件鹰哥已经介绍完毕了,现在来给大家介绍大家最关心的程序了,让鹰哥来一点点介绍。
三、程序部分
- /******************************************************
- *程序:摇摇棒的设计程序
- ** 这一讲的主要内容: 吴鉴鹰摇摇棒的设计和制作
- ** 功能描述:
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- #include
- #define uchar unsigned char
- #define uint unsigned int //宏定义
- #define KEY P3_7 //定义画面切换按键
- uchar KY; //KY作用在后面说明
- uchar disp; //显示汉字指针
- uchar pic=0,num=0; //pic为按键次数;num为中断次数
- uchar code love[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x00,0x20,0x00,0x20,0x00,0x20,
- 0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,
- 0x04,0x10,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x04,0x10,0xF8,0x0F,0x00,0x00,
- 0x00,0x00,0x00,0x00,0xFE,0x07,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,
- 0x00,0x08,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x82,0x20,0x82,0x20,
- 0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*LOVE*/
- };
- uchar code loveyou[] = {
- 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,
- 0x78,0x00,0xFC,0x00,0xFE,0x01,0xFE,0x03,0xFE,0x07,0xFE,0x0F,0xFE,0x1F,0xFC,0x3F,
- 0xF8,0x7F,0xFC,0x3F,0xFE,0x1F,0xFE,0x0F,0xFE,0x07,0xFE,0x03,0xFE,0x01,0xFC,0x00,
- 0x78,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,/*心形图案*/
- };
- uchar code hehe[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0x40,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,
- 0xF0,0x0F,0x08,0x10,0x04,0x20,0x00,0x00,0x00,0x00,0xF0,0x3F,0x08,0x00,0x04,0x00,
- 0x04,0x00,0x04,0x00,0x08,0x00,0xF0,0x3F,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x20,
- 0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0xF0,0x3F,0x08,0x00,0x04,0x00,
- 0x04,0x00,0x04,0x00,0x08,0x00,0xF0,0x3F,0x00,0x00,0x00,0x00,0x04,0x20,0x08,0x10,
- 0xF0,0x0F,0x00,0x00,0x00,0x00,0xC0,0x01,0x40,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*呵呵o(∩_∩)o图案*/
- };
- unsigned char code hanzi[] = {
- /*-- 文字: 欢 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x04,0x24,0x44,0x84,0x64,0x9C,0x40,0x30,0x0F,0xC8,0x08,0x08,0x28,0x18,0x00,0x00,
- //0x10,0x08,0x06,0x01,0x82,0x4C,0x20,0x18,0x06,0x01,0x06,0x18,0x20,0x40,0x80,0x00,
- /*-- 文字: 迎 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x40,0x40,0x42,0xCC,0x00,0x00,0xFC,0x04,0x02,0x00,0xFC,0x04,0x04,0xFC,0x00,0x00,
- //0x00,0x40,0x20,0x1F,0x20,0x40,0x4F,0x44,0x42,0x40,0x7F,0x42,0x44,0x43,0x40,0x00,
- /*-- 文字: 使 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x80,0x60,0xF8,0x07,0x04,0xE4,0x24,0x24,0x24,0xFF,0x24,0x24,0x24,0xE4,0x04,0x00,
- //0x00,0x00,0xFF,0x00,0x80,0x81,0x45,0x29,0x11,0x2F,0x41,0x41,0x81,0x81,0x80,0x00,
- /*-- 文字: 用 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x00,0x00,0xFE,0x22,0x22,0x22,0x22,0xFE,0x22,0x22,0x22,0x22,0xFE,0x00,0x00,0x00,
- //0x80,0x60,0x1F,0x02,0x02,0x02,0x02,0x7F,0x02,0x02,0x42,0x82,0x7F,0x00,0x00,0x00,
- /*-- 文字: 吴 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x00,0x00,0x80,0x9E,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x9E,0x80,0x00,0x00,0x00,
- //0x84,0x84,0x44,0x44,0x24,0x14,0x0C,0x07,0x0C,0x14,0x24,0x44,0x44,0x84,0x84,0x00,
- /*-- 文字: 鉴 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x00,0x00,0x3E,0x00,0x80,0xBF,0x40,0x20,0x58,0x87,0x84,0x0C,0x34,0x04,0x00,0x00,
- //0x02,0x42,0x49,0x49,0x5A,0x6A,0x4A,0x7E,0x4A,0x6A,0x5A,0x49,0x49,0x42,0x02,0x00,
- /*-- 文字: 鹰 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x00,0x00,0xFE,0x22,0x12,0xFA,0x26,0x12,0xFB,0xAE,0xAA,0xFE,0xAA,0xAA,0x02,0x00,
- //0x40,0x30,0x0F,0x40,0x40,0x5E,0x52,0x53,0x56,0x52,0x1A,0x56,0x90,0x70,0x00,0x00,
- /*-- 文字: 的 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x00,0xF8,0x0C,0x0B,0x08,0x08,0xF8,0x40,0x30,0x8F,0x08,0x08,0x08,0xF8,0x00,0x00,
- //0x00,0x7F,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,0x00,0x43,0x80,0x40,0x3F,0x00,0x00,
- /*-- 文字: 摇 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x10,0x10,0x10,0xFF,0x90,0x00,0x94,0x64,0x44,0x54,0xE2,0x42,0x63,0x5A,0x00,0x00,
- //0x02,0x42,0x81,0x7F,0x00,0x00,0x02,0x7A,0x42,0x42,0x7F,0x42,0x42,0xFA,0x02,0x00,
- /*-- 文字: 摇 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x10,0x10,0x10,0xFF,0x90,0x00,0x94,0x64,0x44,0x54,0xE2,0x42,0x63,0x5A,0x00,0x00,
- //0x02,0x42,0x81,0x7F,0x00,0x00,0x02,0x7A,0x42,0x42,0x7F,0x42,0x42,0xFA,0x02,0x00,
- /*-- 文字: 棒 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x10,0x10,0xD0,0xFF,0x90,0x10,0x44,0x54,0xD4,0x74,0x5F,0x54,0xD4,0x54,0x44,0x00,
- //0x04,0x03,0x00,0xFF,0x00,0x01,0x12,0x11,0x14,0x14,0xFF,0x14,0x14,0x11,0x12,0x00,
- //就
- 0x04,0x10,0xE4,0x4B,0x25,0x82,0x26,0x7E,0x24,0x02,0xE4,0x0B,0x04,0x90,0x20,0x6,
- 0x20,0x1C,0xFF,0x03,0x20,0x00,0xE2,0x3F,0x2C,0x40,0x20,0x40,0x20,0x70,0x00,0x00,/*"就",0*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x00,0x02,0x02,0xF2,0x82,0x92,0x92,0x92,0x9A,0xFE,0x56,0x92,0x63,0x92,0x22,
- 0x92,0x32,0xFE,0x4A,0x92,0x46,0x92,0x42,0xF2,0x82,0x02,0x02,0x00,0x00,0x00,0x00,/*"要",1*/
- /* (16 X 16 , 宋体 ) */
- 0x04,0x00,0x04,0xFE,0x04,0x02,0xF4,0x02,0x84,0x12,0xD4,0x3A,0xA5,0x16,0xA6,0x13,
- 0xA4,0x12,0xD4,0x1A,0x84,0x32,0xF4,0x42,0x04,0x82,0x04,0x7E,0x04,0x00,0x00,0x00,/*"离",2*/
- /* (16 X 16 , 宋体 ) */
- 0x80,0x00,0x82,0x80,0x82,0x40,0x82,0x30,0xFE,0x0F,0x82,0x00,0x82,0x00,0x82,0x00,
- 0x82,0x00,0x82,0x00,0xFE,0xFF,0x82,0x00,0x82,0x00,0x82,0x00,0x80,0x00,0x00,0x00,/*"开",3*/
- /* (16 X 16 , 宋体 ) */
- 0x80,0x00,0x90,0x80,0x8C,0x80,0x84,0x84,0x84,0x46,0x84,0x49,0xF5,0x28,0x86,0x10,
- 0x84,0x10,0x84,0x2C,0x84,0x23,0x84,0x40,0x94,0x80,0x8C,0x00,0x80,0x00,0x00,0x00,/*"安",4*/
- /* (16 X 16 , 宋体 ) */
- 0x10,0x01,0x88,0x00,0xC4,0xFF,0x23,0x48,0xAE,0x29,0x68,0x8D,0x2F,0xFB,0x28,0x09,
- 0xAE,0xAC,0x20,0x48,0xD8,0x37,0x17,0x08,0x10,0x36,0xF0,0x41,0x10,0x80,0x00,0x00,/*"徽",5*/
- /* (16 X 16 , 宋体 ) */
- 0x04,0x20,0x84,0x60,0x84,0x20,0xFC,0x1F,0x84,0x10,0x84,0x10,0x00,0x40,0xFE,0x44,
- 0x92,0x44,0x92,0x44,0xFE,0x7F,0x92,0x44,0x92,0x44,0xFE,0x44,0x00,0x40,0x00,0x00,/*"理",6*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0xFC,0x3F,
- 0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x00,0x20,0x00,0x00,/*"工",7*/
- /* (16 X 16 , 宋体 ) */
- 0x20,0x80,0x20,0x80,0x20,0x40,0x20,0x20,0x20,0x10,0x20,0x0C,0x20,0x03,0xFF,0x00,
- 0x20,0x03,0x20,0x0C,0x20,0x10,0x20,0x20,0x20,0x40,0x20,0x80,0x20,0x80,0x00,0x00,/*"大",8*/
- /* (16 X 16 , 宋体 ) */
- 0x40,0x04,0x30,0x04,0x11,0x04,0x96,0x04,0x90,0x04,0x90,0x44,0x91,0x84,0x96,0x7,
- 0x90,0x06,0x90,0x05,0x98,0x04,0x14,0x04,0x13,0x04,0x50,0x04,0x30,0x04,0x00,0x00,/*"学",9*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x40,0x02,0x80,0xE2,0x7F,
- 0x22,0x00,0x12,0x00,0x0A,0x00,0x06,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"了",10*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x7C,0x10,0xFE,0x3B,
- 0xFE,0x3B,0x7C,0x10,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
- };
- unsigned char code dayday[] = {
- 0x40,0x80,0x40,0x80,0x42,0x40,0x42,0x20,0x42,0x10,0x42,0x0C,0x42,0x03,0xFE,0x00,
- 0x42,0x03,0x42,0x0C,0x42,0x10,0x42,0x20,0x42,0x40,0x40,0x80,0x40,0x80,0x00,0x00,/*"天",0*/
- /* (16 X 16 , 宋体 ) */
- 0x40,0x80,0x40,0x80,0x42,0x40,0x42,0x20,0x42,0x10,0x42,0x0C,0x42,0x03,0xFE,0x00,
- 0x42,0x03,0x42,0x0C,0x42,0x10,0x42,0x20,0x42,0x40,0x40,0x80,0x40,0x80,0x00,0x00,/*"天",1*/
- /* (16 X 16 , 宋体 ) */
- 0x80,0x00,0x82,0x80,0x82,0x40,0x82,0x30,0xFE,0x0F,0x82,0x00,0x82,0x00,0x82,0x00,
- 0x82,0x00,0x82,0x00,0xFE,0xFF,0x82,0x00,0x82,0x00,0x82,0x00,0x80,0x00,0x00,0x00,/*"开",2*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x10,0x00,0x0C,0x80,0x03,0x00,0x00,0x00,0x00,0xE0,0x3F,0x02,0x40,0x04,0x40,
- 0x18,0x40,0x00,0x40,0x00,0x40,0x00,0x78,0x40,0x00,0x80,0x01,0x00,0x0E,0x00,0x00,/*"心",3*/
- /* (16 X 16 , 宋体 ) */
- };
- unsigned char code damogu[] = {
- 0x20,0x80,0x20,0x80,0x20,0x40,0x20,0x20,0x20,0x10,0x20,0x0C,0x20,0x03,0xFF,0x00,
- 0x20,0x03,0x20,0x0C,0x20,0x10,0x20,0x20,0x20,0x40,0x20,0x80,0x20,0x80,0x00,0x00,/*"大",0*/
- /* (16 X 16 , 宋体 ) */
- 0x10,0x04,0x60,0x04,0x02,0x7C,0x0C,0x03,0xC0,0x80,0x04,0x88,0xE4,0x4B,0xAF,0x2A,
- 0xA4,0x1A,0xA4,0x0E,0xA4,0x1A,0xAF,0x2A,0xE4,0x4B,0x04,0x88,0x00,0x80,0x00,0x00,/*"漠",1*/
- /* (16 X 16 , 宋体 ) */
- 0x02,0x42,0x02,0x82,0xF2,0x7F,0x8A,0x00,0x46,0x80,0x00,0x60,0xFC,0x1F,0x04,0x00,
- 0xFC,0x7F,0x04,0x28,0x02,0x10,0xFE,0x61,0x03,0x0E,0x02,0x30,0x00,0x40,0x00,0x00,/*"孤",2*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x40,0x00,0x30,0xFE,0x0F,0x22,0x40,0x12,0x40,0xFA,0x5E,0x26,0x52,0x12,0x53,
- 0xFB,0x56,0xAE,0x52,0xAA,0x1A,0xFE,0x56,0xAA,0x90,0xAA,0x70,0x02,0x00,0x00,0x00,/*"鹰",3*/
- /* (16 X 16 , 宋体 ) */
- };
- unsigned char code womenbiye[] = {
- 0x20,0x00,0x24,0x08,0x24,0x48,0x24,0x84,0xFE,0x7F,0x23,0x02,0x22,0x41,0x20,0x40,
- 0x20,0x20,0xFF,0x13,0x20,0x0C,0x22,0x14,0x2C,0x22,0xA0,0x41,0x20,0xF8,0x00,0x00,/*"我",0*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x01,0x80,0x00,0x60,0x00,0xF8,0xFF,0x07,0x00,0x00,0x00,0xF8,0xFF,0x01,0x00,
- 0x06,0x00,0x00,0x00,0x04,0x00,0x04,0x40,0x04,0x80,0xFC,0x7F,0x00,0x00,0x00,0x00,/*"们",1*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x04,0x00,0x04,0xFF,0x05,0x88,0x04,0x88,0x04,0x48,0x04,0x48,0x04,0x00,0xFF,
- 0x7F,0x04,0x88,0x04,0x84,0x04,0x84,0x04,0x82,0x04,0xE0,0x04,0x00,0x04,0x00,0x00,/*"毕",2*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x40,0x10,0x40,0x60,0x40,0x80,0x43,0x00,0x40,0xFF,0x7F,0x00,0x40,0x00,0x40,
- 0x00,0x40,0xFF,0x7F,0x00,0x42,0x00,0x41,0xC0,0x40,0x30,0x40,0x00,0x40,0x00,0x00,/*"业",3*/
- /* (16 X 16 , 宋体 ) */
- 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,0xFC,0x0F,0x04,0x04,0xFC,0x0F,0x00,0x00,0x10,0x44,0x10,0x82,0xFF,0x7F,
- 0x90,0x00,0xC8,0x40,0x09,0x4F,0x0E,0x60,0x08,0x5C,0xE8,0x43,0x08,0x40,0x00,0x00,/*"啦",4*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"!",5*/
- 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,
- /* (16 X 16 , 宋体 ) */
- };
- unsigned char code LiuShiShi[] = {
- /*-- 文字: 刘 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x08,0x28,0x48,0x89,0x0E,0x88,0x78,0x08,0x08,0x00,0xF8,0x00,0x00,0xFF,0x00,0x00,
- 0x40,0x20,0x10,0x09,0x06,0x19,0x60,0x00,0x00,0x00,0x0F,0x40,0x80,0x7F,0x00,0x00,
- /*-- 文字: 诗 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x40,0x40,0x42,0xCC,0x00,0x40,0x48,0x48,0x48,0x7F,0x48,0xC8,0x48,0x48,0x40,0x00,
- 0x00,0x00,0x00,0x7F,0x20,0x12,0x0A,0x32,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x00,
- /*-- 文字: 诗 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x40,0x40,0x42,0xCC,0x00,0x40,0x48,0x48,0x48,0x7F,0x48,0xC8,0x48,0x48,0x40,0x00,
- 0x00,0x00,0x00,0x7F,0x20,0x12,0x0A,0x32,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x00,
- };
- unsigned char code Ytzgzj[] = {
- {0x00,0x08,0x00,0x04,0x00,0x03,0xE0,0x00,0x00,0x00,0x00,0x40,0x00,0x80,0xFF,0x7F},
- {0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x40,0x00,0x80,0x01,0x00,0x0E,0x00,0x00},/*"小",0*/
- /* (16 X 16 , 宋体 ) */
- 0x40,0x00,0x40,0x00,0x42,0x00,0xCC,0x7F,0x00,0x20,0x40,0x12,0x48,0x0A,0x48,0x32,
- 0x48,0x02,0x7F,0x42,0x48,0x82,0xC8,0x7F,0x48,0x02,0x48,0x02,0x40,0x02,0x00,0x00,/*"诗",1*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x80,0xFE,0x6F,0x42,0x08,0x42,0x08,0x42,0x28,0xFE,0xCF,0x00,0x00,0x42,0x00,
- 0xA2,0x2F,0x9E,0xC8,0x82,0x08,0xA2,0x08,0xC2,0x28,0xBE,0xCF,0x00,0x00,0x00,0x00,/*"照",2*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x80,0xFE,0x7F,0x02,0x00,0xF2,0x7F,0x12,0x21,0x12,0x12,0xF2,0x89,0x00,0x80,
- 0xF2,0x4F,0x1A,0x20,0x16,0x18,0xD2,0x17,0x12,0x20,0xF2,0x4F,0x02,0x80,0x00,0x00,/*"顾",3*/
- /* (16 X 16 , 宋体 ) */
- 0x10,0x40,0x10,0x22,0xF0,0x15,0x1F,0x08,0x10,0x16,0xF0,0x61,0x00,0x00,0x80,0x00,
- 0x82,0x40,0x82,0x80,0xE2,0x7F,0x92,0x00,0x8A,0x00,0x86,0x00,0x80,0x00,0x00,0x00,/*"好",4*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xFF,0x88,0x44,0x8C,0x44,0x8A,0x44,0x89,0x44,
- 0x88,0x44,0x88,0x44,0x88,0x44,0xF8,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"自",5*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x00,0x00,0x00,0x82,0x3F,0x82,0x40,0x82,0x40,0x82,0x40,0x82,0x40,0x82,0x40,
- 0x82,0x40,0x82,0x40,0x82,0x40,0xFE,0x40,0x00,0x40,0x00,0x78,0x00,0x00,0x00,0x00,/*"己",6*/
- /* (16 X 16 , 宋体 ) */
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x33,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*/
- /* (16 X 16 , 宋体 ) */
- };
- /*****函数声明*****/
- void display1_ltor(void);
- void display2_ltor(void);
- void display2_rtol(void);
- void display3(void);
- void display4(void);
- void display5(void);
- void display6(void);
- void display7(void);
- void display8(void);
- void display9(void);
- /******************************************************
- *程序:void DelayUs(uint N)
- ** 功能描述: n(us)延时子程序
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- void DelayUs(uint N)
- {
- uint x;
- for(x=0; x<=N;x++);
- }
- /******************************************************
- *程序:void intersvr0(void) interrupt 0
- ** 功能描述: 中断服务程序
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- void intersvr0(void) interrupt 0
- {
- //;
- KY=~KY; //每个摇动来回水银开关会在摆幅两端分别产生下降沿中断,只提取其中一次(从左向右摇才显示)
- if(KY==0)
- {
- num++; //计算中断次数
- switch(pic) //选择画面
- {
- case 0:{display1_ltor();}break;
- case 1:{display2_ltor();}break;
- case 2:{display3();}break;
- case 3:{display4();}break;
- case 4:{display5();}break;
- case 5:{display6();}break;
- case 6:{display7();}break;
- case 7:{display8();}break;
- case 8:{display9();}break;
- default:{display1_ltor();}
- }
- }
- }
- /******************************************************
- *程序:void display1_ltor(void)
- ** 功能描述: 显示子程序1(汉字)
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- void display1_ltor(void)
- {
- uchar i;
- if(num>10){disp++;num=0;} //12个汉字分为3次显示完(每次显示4个),每中断10次切换
- if(disp>2)disp=0;
- DelayUs(5200); //此处延时时间依各硬件差别而各不相同,试着调整使得显示内容居中即可
- for(i=0;i<64;i++)
- {
- P0=~hanzi[disp*128+i*2];
- P2=~hanzi[disp*128+i*2+1];
- DelayUs(100);
- }
- }
- /******************************************************
- *程序:void display2_ltor(void)
- ** 功能描述: 显示子程序2(LOVE)
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- void display2_ltor(void)
- {
- uchar i;
- DelayUs(4000);
- for(i=0;i<64;i++)
- {
- P0=~love[i*2];
- P2=~love[i*2+1];
- DelayUs(140);
- }
- }
- /******************************************************
- *程序:void display3(void)
- ** 功能描述: 显示子程序3(心形图案)
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- void display3(void)
- {
- uchar i;
- DelayUs(4000);
- for(i=0;i<64;i++)
- {
- P0=~loveyou[i*2];
- P2=~loveyou[i*2+1];
- DelayUs(120);
- }
- }
- /******************************************************
- *程序:void display4(void)
- ** 功能描述: 显示子程序4(呵呵o(∩_∩)o图案)
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- void display4(void)
- {
- uchar i;
- DelayUs(4000);
- for(i=0;i<64;i++)
- {
- P0=~hehe[i*2];
- P2=~hehe[i*2+1];
- DelayUs(120);
- }
- }
- /******************************************************
- *程序:void display5(void)
- ** 功能描述: 显示子程序5(天天开心)
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- void display5(void)
- {
- uchar i;
- DelayUs(4000);
- for(i=0;i<64;i++)
- {
- P0=~dayday[i*2];
- P2=~dayday[i*2+1];
- DelayUs(120);
- }
- }
- /******************************************************
- *程序:void display6(void)
- ** 功能描述: 显示子程序6(天天开心)
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- void display6(void)
- {
- uchar i;
- DelayUs(4000);
- for(i=0;i<64;i++)
- {
- P0=~damogu[i*2];
- P2=~damogu[i*2+1];
- DelayUs(120);
- }
- }
- /******************************************************
- *程序:void display7(void)
- ** 功能描述: 显示子程序7(天天开心)
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- void display7(void)
- {
- uchar i;
- if(num>10){disp++;num=0;} //8个汉字分为3次显示完(每次显示4个),每中断10次切换
- if(disp>1)disp=0;
- DelayUs(5200); //此处延时时间依各硬件差别而各不相同,试着调整使得显示内容居中即可
- for(i=0;i<64;i++)
- {
- P0=~womenbiye[disp*128+i*2];
- P2=~womenbiye[disp*128+i*2+1];
- DelayUs(100);
- }
- }
- /******************************************************
- *程序:void display8(void)
- ** 功能描述: 显示子程序8(天天开心)
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- void display8(void)
- {
- uchar i;
- DelayUs(4000);
- for(i=0;i<64;i++)
- {
- P0=~LiuShiShi[i*2];
- P2=~LiuShiShi[i*2+1];
- DelayUs(120);
- }
- }
- /******************************************************
- *程序:void display9(void)
- ** 功能描述: 小诗照顾好自己
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- void display9(void)
- {
- uchar i;
- if(num>10){disp++;num=0;} //8个汉字分为2次显示完(每次显示4个),每中断10次切换
- if(disp>1)disp=0;
- DelayUs(5200); //此处延时时间依各硬件差别而各不相同,试着调整使得显示内容居中即可
- for(i=0;i<64;i++)
- {
- P0=~Ytzgzj[disp*128+i*2];
- P2=~Ytzgzj[disp*128+i*2+1];
- DelayUs(100);
- }
- }
- /******************************************************
- *程序:void main(void)
- ** 功能描述: 主函数
- ** 输 入:
- ** 内容:
- ** 输 出:
- **
- ** 全局变量:
- ** 调用模块:
- **
- ** 作 者: 吴鉴鹰
- ** 日 期: 14.02.22
- 备注:有什么错误的地方,欢迎各大烧友指正
- O(∩_∩)O~
- *******************************************************/
- void main(void)
- {
- IT0=1;
- EX0=1;
- EA=1; //开中断,下降沿中断
- KY=0;
- KEY=1;
- while(1) //主程序中只检测按键
- {
- if(KEY==0) //画面切换键按下
- {
- DelayUs(10000); //按键去抖
- if(KEY==0) //这个地方多了一个分号,谢谢 lhxtzlhxtz的提醒!这是我的疏忽,向大家道歉,只能以后发表更多有价值的帖子表示我的歉意了!
- pic++;
- while(KEY==0);
- }
- if(pic>8)pic=0;
- }
- }
- /*****END*****/
复制代码
QQ群1号:332164870【1000人群】(已满) 群内已有成员1000余人!欢迎大家加入学习,交流,咨询!三者加一即可!
`
|