需要的自己拿吧
摇摇棒的电路图:
摇摇棒的元件清单:
名称 描述 标号 单板数量
瓷片电容 22p C1, C2 2
电解电容 10uF C3 1
电源指示灯 LED 发光二极管 D1 1
二极管IN4007 High Conductance Fast Diode D2 1
LED LED 发光二极管 D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, D18 16
JTAG10 下载接头 J1 1
按键 Switch K1 1
弹簧开关 Switch K2 1
电源端口 Header, 2-Pin P1 1
单排插针 Header, 3-Pin P2 1
电阻 1k R1, R2, R3, R4 2 R2,R3可不焊接
拨动开关 三位波动开关 S1 1
AT89s52 单片机 U4 1
晶振 12M Y1 1
芯片插座 单片机芯片座 U4 1
很多亲们经常问摇摇棒中的字怎样取字模,今天在这里描述一下; 以“欢”为例作为讲解 程序中的“欢”点阵是这样的: //-- 欢 -- 0x04,0x10,0x34,0x08,0xC4,0x06,0x04,0x01, 0xC4,0x82,0x3C,0x8C,0x20,0x40,0x10,0x30, 0x0F,0x0C,0xE8,0x03,0x08,0x0C,0x08,0x10, 0x28,0x60,0x18,0xC0,0x00,0x40,0x00,0x00, 为了直观,我们把它按PCB布线的方法把上面的点阵排类一下
其中1为亮 ,0为LED灭(为什么1是亮,0是灭,请亲们看一下程序和电路,2个结合起来看一下就明白了,这里就不再说明) 接下来为了方便看哪些是亮的,我们把0去掉
file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image002.jpg 看到了吗,一个很大的“欢”字就出来了。上面的点阵我们是手动排列的。接下来教大家如何用软件取字模。 file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image006.jpg 字体设置为:新宋体然后输入“欢”,点生产字模 file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image008.jpg 点完后我们会得到如下的字模: 欢(0)
{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},/*"欢 /* (16 X 16 , 新宋体 ) */
这个就是我们要的“欢”字的字模,很多亲们就会问,为什么软件取出来的字模和程序中的不一样,那是因为程序中的字模,我们是手动排列的。用软件取出来的字模也是可以的。
摇摇棒程序:
- #include <AT89X52.h>
- #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[] = {
- 0x40,0x08,0x44,0x08,0x44,0x04,0x44,0x04,
- 0x44,0x02,0x44,0x3E,0x7F,0x49,0xC4,0x48,
- 0xC4,0x44,0x44,0x44,0x64,0x42,0x54,0x42,
- 0x4E,0x40,0x44,0x70,0x40,0x00,0x00,0x00,/*"老",0*/
- 0x00,0x40,0xFC,0x27,0x00,0x10,0x00,0x0E,
- 0xFF,0x01,0x00,0x00,0xF2,0x0F,0x12,0x00,
- 0x12,0x00,0x12,0x00,0xFE,0xFF,0x12,0x00,
- 0x12,0x04,0x12,0x08,0xF2,0x07,0x00,0x00,/*"师",0*/
- 0x10,0x80,0x10,0x43,0xF0,0x22,0x1F,0x14,
- 0x10,0x0C,0xF0,0x73,0x80,0x20,0x82,0x00,
- 0x82,0x40,0x82,0x80,0xF2,0x7F,0x8A,0x00,
- 0x86,0x00,0x82,0x00,0x80,0x00,0x00,0x00,/*"好",0*/
- 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,/*"!",0*/
- 0x20,0x22,0x30,0x23,0xAC,0x22,0x63,0x12,
- 0x10,0x12,0x40,0x00,0x20,0x00,0x50,0x7E,
- 0x4C,0x42,0x43,0x42,0x44,0x42,0x48,0x42,
- 0x30,0x7E,0x60,0x00,0x20,0x00,0x00,0x00,/*"给",0*/
- 0x00,0x00,0x80,0x00,0x80,0x00,0x40,0x00,
- 0x20,0x00,0x10,0x00,0x0C,0x00,0xE3,0x7F,
- 0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,
- 0x60,0x00,0xC0,0x00,0x40,0x00,0x00,0x00,/*"个",1*/
- 0x10,0x08,0x61,0xF8,0x06,0x07,0xE0,0x00,
- 0x04,0x00,0xA4,0xFF,0xA4,0x08,0xEF,0x07,
- 0xA4,0x14,0xA4,0x08,0xE4,0x07,0xAF,0x44,
- 0xA4,0x88,0xA4,0x7F,0x24,0x00,0x00,0x00,/*"满",2*/
-
- 0x80,0x00,0x40,0x80,0x20,0x40,0x98,0x20,
- 0x87,0x10,0x82,0x0F,0x80,0x00,0x80,0x00,
- 0x83,0x20,0x84,0x40,0x98,0x3F,0x30,0x00,
- 0x60,0x00,0xC0,0x00,0x40,0x00,0x00,0x00,/*"分",3*/
- };
- /*****函数声明*****/
- void display1_ltor(void);
- void display2_ltor(void);
- void display2_rtol(void);
- void display3(void);
- void display4(void);
- /*****n(us)延时子程序*****/
- void DelayUs(uint N)
- {
- uint x;
- for(x=0; x<=N;x++);
- }
- /*****中断服务程序*****/
- 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;
- default:{display1_ltor();}
- }
- }
- }
- /*****显示子程序1(汉字)*****/
- void display1_ltor(void)
- {
- uchar i;
- if(num>10){disp++;num=0;} //每中断10次切换
- if(disp>1)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);
- }
- }
- /*****显示子程序2(LOVE)*****/
- 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);
- }
- }
- /*****显示子程序3(心形图案)*****/
- void display3(void)
- {
- uchar i;
- DelayUs(4000);
- for(i=0;i<64;i++)
- {
- P0=~loveyou[i*2];
- P2=~loveyou[i*2+1];
- DelayUs(120);
- }
- }
- /*****显示子程序4(呵呵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 main(void)
- {
- IT0=1;
- EX0=1;
- EA=1; //开中断,下降沿中断
- KY=0;
- while(1) //主程序中只检测按键
- {
- if(KEY==0) //画面切换键按下
- {
- DelayUs(10000); //按键去抖
- if(KEY==0);
- pic++;}
- if(pic>3)pic=0;
- }
- }
- /*****END*****/
复制代码
摇摇棒课程设计报告及其详细的制作文件下载:
摇摇棒配套资料.zip
(14.04 MB, 下载次数: 131)
|