摇摇棒程序与电路设计说明书Word文档下载推荐.docx

上传人:b****6 文档编号:18760911 上传时间:2023-01-01 格式:DOCX 页数:9 大小:454.90KB
下载 相关 举报
摇摇棒程序与电路设计说明书Word文档下载推荐.docx_第1页
第1页 / 共9页
摇摇棒程序与电路设计说明书Word文档下载推荐.docx_第2页
第2页 / 共9页
摇摇棒程序与电路设计说明书Word文档下载推荐.docx_第3页
第3页 / 共9页
摇摇棒程序与电路设计说明书Word文档下载推荐.docx_第4页
第4页 / 共9页
摇摇棒程序与电路设计说明书Word文档下载推荐.docx_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

摇摇棒程序与电路设计说明书Word文档下载推荐.docx

《摇摇棒程序与电路设计说明书Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《摇摇棒程序与电路设计说明书Word文档下载推荐.docx(9页珍藏版)》请在冰豆网上搜索。

摇摇棒程序与电路设计说明书Word文档下载推荐.docx

/**********************************************************

程序名称:

LED摇摇棒显示64*16像素

简要说明:

外部中断方式INT0显示;

取模方式:

纵向取模、字节倒序

编写:

JiangX.net

最后更新:

08/11/15晚

**********************************************************/

#include<

AT89X52.h>

#defineucharunsignedchar

#defineuintunsignedint//宏定义

#defineKEYP3_0//定义画面切换按键

ucharKY;

//KY作用在后面说明

uchardisp;

//显示汉字指针

ucharpic=0,num=0;

//pic为按键次数;

num为中断次数

ucharcodelove[]={

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*/

};

ucharcodeloveyou[]={

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,/*心形图案*/

ucharcodehehe[]={

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图案*/

unsignedcharcodehanzi[]={

//--rong--

0x84,0x10,0x64,0x10,0x24,0x08,0x24,0x05,

0xAF,0xFC,0x24,0x46,0x24,0x45,0xB4,0x44,

0x24,0x45,0x24,0x46,0xAF,0xFC,0x24,0x05,

0x24,0x08,0xA6,0x18,0x64,0x08,0x00,0x00,

//"

xin"

0x00,0x40,0x00,0x30,0xFC,0x0F,0x44,0x00,

0x44,0x00,0xC2,0x7F,0x43,0x80,0x42,0x40,

0x20,0x30,0x1F,0x0C,0xD0,0x03,0x10,0x0C,

0x10,0x30,0x50,0xC0,0x30,0x40,0x00,0x00,

0x10,0x30,0x50,0xC0,0x30,0x40,0x00,0x00,

幸"

0x20,0x00,0x20,0x08,0x24,0x09,0x24,0x09,

0x64,0x09,0xA4,0x09,0x24,0x09,0x3F,0xFF,

0x24,0x09,0xA4,0x09,0x64,0x09,0xA6,0x09,

0x24,0x0D,0x30,0x08,0x20,0x00,0x00,0x00,

福"

0x10,0x02,0x10,0x01,0x91,0x00,0xD6,0xFF,

0xB0,0x00,0x02,0xFF,0x7A,0x49,0x4A,0x49,

0x4A,0x49,0x4A,0x7F,0x4A,0x49,0x4A,0x49,

0x7B,0x49,0x82,0xFF,0x00,0x01,0x00,0x00,

//--快--

0x80,0x00,0x70,0x00,0x00,0x00,0xFF,0xFF,

0x10,0x82,0x20,0x42,0x10,0x22,0x10,0x1A,

0xFF,0x07,0x10,0x0A,0x10,0x12,0x10,0x22,

0xF8,0x43,0x10,0xC2,0x00,0x42,0x00,0x00,

//--乐--

0x00,0x00,0x80,0x40,0xC0,0x20,0xBC,0x10,

0x84,0x0C,0x84,0x40,0x84,0x80,0xF4,0x7F,

0x82,0x00,0x82,0x00,0x83,0x04,0x82,0x08,

0x80,0x30,0xC0,0x60,0x80,0x00,0x00,0x00,

//--每--

0x00,0x01,0x10,0x01,0x08,0x1D,0xF7,0x13,

0x14,0x11,0x14,0x11,0x34,0x13,0x54,0x15,

0x14,0x51,0x14,0x91,0x14,0x71,0xFC,0x1F,

0x16,0x11,0x84,0x01,0x00,0x01,0x00,0x00,

//--一--

0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,

0x80,0x00,0xC0,0x00,0x80,0x00,0x00,0x00,

//--天--

0x40,0x80,0x42,0x80,0x42,0x40,0x42,0x20,

0x42,0x10,0x42,0x0C,0x42,0x03,0xFE,0x00,

0x42,0x03,0x42,0x0C,0x42,0x10,0x42,0x20,

0x43,0x40,0x62,0xC0,0x40,0x40,0x00,0x00,

//--!

--

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

/*****函数声明*****/

voiddisplay1(void);

voiddisplay2(void);

voiddisplay3(void);

voiddisplay4(void);

/*****n(us)延时子程序*****/

voidDelayUs(uintN)

{

uintx;

for(x=0;

x<

=N;

x++);

}

/*****中断服务程序*****/

voidintersvr0(void)interrupt0using1

KY=~KY;

//每个摇动来回水银开关会在摆幅两端分别产生下降沿中断,只提取其中一次(从左向右摇才显示)

if(KY==0)

num++;

//计算中断次数

switch(pic)//选择画面

case0:

{display1();

}break;

case1:

{display2();

case2:

{display3();

case3:

{display4();

default:

}

/*****显示子程序1(汉字)*****/

voiddisplay1(void)

uchari;

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);

/*****显示子程序2(LOVE)*****/

voiddisplay2(void)

DelayUs(4000);

P0=~love[i*2];

P2=~love[i*2+1];

DelayUs(120);

/*****显示子程序3(心形图案)*****/

voiddisplay3(void)

P0=~loveyou[i*2];

P2=~loveyou[i*2+1];

/*****显示子程序4(呵呵o(∩_∩)o图案)*****/

voiddisplay4(void)

P0=~hehe[i*2];

P2=~hehe[i*2+1];

/*****主函数*****/

voidmain(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;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育 > 少儿英语

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1