第一范文网 - 专业文章范例文档资料分享平台

电子音乐盒的设计

来源:用户分享 时间:2025/5/24 15:33:41 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

附录2 程序清单

#include

typedef unsigned char uchar; typedef unsigned int uint; sbit RS=P2^0; sbit RW=P2^1; sbit E= P2^2; sbit BEEP=P2^7; sbit k1=P1^0; sbit k2=P1^1; sbit k3=P1^2; sbit k4=P1^3; char count2;

uchar a,b,c,aa,num; uchar num1,num2;

uchar code table1[]={

0x12,0x22,0x34,0x84,0x74,0x54,0x38,0x42,0x32,0x22,0x42,0x34,0x84,0x72,0x82,0x94,0xA8,0x08,

0x32,0x31,0x21,0x32,0x52,0x32,0x31,0x21,0x32,0x62,

0x32,0x31,0x21,0x32,0x82,0x71,0x81,0x71,0x51,0x32,0x22, 0x32,0x31,0x21,0x32,0x82,0x71,0x81,0x71,0x51,0x32,0x22, 0x32,0x31,0x21,0x32,0x52,0x32,0x31,0x21,0x32,0x62, 0x32,0x31,0x21,0x32,0x83,0x82,0x71,0x72,0x02, 0x63,0xA1,0xA2,0x62,0x92,0x82,0x52,

0x31,0x51,0x63,0x51,0x63,0x51,0x63,0x51,0x62,0x82,0x7C,0x02, 0x61,0x71,0x82,0x71,0x62,0xA2,0x71,0x76, 0x61,0x71,0x82,0x71,0x62,0x52,0x31,0x36,

0x61,0x71,0x82,0x71,0x62,0xA3,0x73,0x62,0x53, 0x42,0x63,0x83,0x83,0x91,0x91,

0x61,0x71,0x82,0x71,0x62,0x0A2,0x71,0x76, 0x61,0x71,0x82,0x71,0x62,0x52,0x31,0x36,

0x61,0x71,0x82,0x71,0x62,0xA3,0x73,0x62,0x53, 0x42,0x82,0x88,0x02,0x74,0x93,0x89,0xff };

uchar code table2[]={

0x12,0x12,0x22,0x32,0x31,0x22,0x21,0x22,

0x21,0x31,0x51,0x52,0x31,0x52,0x61,0x15,0x14,

0x51,0x52,0x31,0x52,0x62,0x13,0x11,0x13,0x32,0x28,0x08,0x28, 0x31,0x32,0x31,0x32,0x11,0x21,0x51,0x52,0x51,0x52, 0x51,0x51,0x31,0x32,0x31,0x32,0x81,0x72,0x63,

0x62,0x71,0x81,0x72,0x61,0x61,0x52,0x31,0x21,0x32,0x51,0x54,

0x22,0x12,0x11,0x12,0x11,0x12,0x12,0x14,0x26,0x32,0x26,

0x32,0x61,0x51,0x51,0x31,0x31,0x21,0x31,0x51,0x61,0x51,0x31,0x51, 0x02,0x32,0x81,0x81,0x81,0x81,0x62,0x52,0x34, 0x31,0x81,0x81,0x81,0x61,0x91,0x82, 0x51,0x51,0x51,0x51,0x31,0x61,0x53,

0x21,0x11,0x21,0x11,0x22,0x11,0x21,0x26,

0x32,0x61,0x51,0x51,0x31,0x31,0x21,0x31,0x51,0x61,0x51,0x31,0x51,0x52, 0x31,0x31,0x81,0x81,0x81,0x61,0x91,0x81,0x61,0x31,0x56,

0x32,0x32,0x81,0x81,0x81,0x81,0x91,0x81,0x61,0x81,0x61,0x51,0x31,0x51,0x34, 0x21,0x31,0x51,0x31,0x21,0x11,0x61,0x21,0x16,0xff };

uchar code table3[]={

0x26,0x20,0x20,0x20,0x20,0x20,0x26,0x10,0x20,0x10,0x20,0x80,0x26,0x20,0x30,0x20,

0x30,0x20,0x39,0x10,0x30,0x10,0x30,0x80,0x26,0x20,0x20,0x20,0x20,0x20,0x1c,0x20,

0x20,0x80,0x2b,0x20,0x26,0x20,0x20,0x20,0x2b,0x10,0x26,0x10,0x2b,0x80,0x26,0x20,

0x30,0x20,0x30,0x20,0x39,0x10,0x26,0x10,0x26,0x60,0x40,0x10,0x39,0x10,0x26,0x20,

0x30,0x20,0x30,0x20,0x39,0x10,0x26,0x10,0x26,0x80,0x26,0x20,0x2b,0x10,0x2b,0x10,

0x2b,0x20,0x30,0x10,0x39,0x10,0x26,0x10,0x2b,0x10,0x2b,0x20,0x2b,0x40,0x40,0x20,

0x20,0x10,0x20,0x10,0x2b,0x10,0x26,0x30,0x30,0x80,0x18,0x20,0x18,0x20,0x26,0x20,

0x20,0x20,0x20,0x40,0x26,0x20,0x2b,0x20,0x30,0x20,0x30,0x20,0x1c,0x20,0x20,0x20,

0x20,0x80,0x1c,0x20,0x1c,0x20,0x1c,0x20,0x30,0x20,0x30,0x60,0x39,0x10,0x30,0x10,

0x20,0x20,0x2b,0x10,0x26,0x10,0x2b,0x10,0x26,0x10,0x26,0x10,0x2b,0x10,0x2b,0x80,

0x18,0x20,0x18,0x20,0x26,0x20,0x20,0x20,0x20,0x60,0x26,0x10,0x2b,0x20,0x30,0x20,

0x30,0x20,0x1c,0x20,0x20,0x20,0x20,0x80,0x26,0x20,0x30,0x10,0x30,0x10,0x30,0x20,

0x39,0x20,0x26,0x10,0x2b,0x10,0x2b,0x20,0x2b,0x40,0x40,0x10,0x40,0x10,0x20,0x10,

0x20,0x10,0x2b,0x10,0x26,0x30,0x30,0x80,0xff };

uchar code qz[]={ 0xff,0xff,

0xFC,0x8E, 0xFC,0xED, 0xFD,0x43, 0xFD,0x6A, 0xFD,0xB3, 0xFD,0xF3, 0xFE,0x2D, 0xFE,0x47, 0xFE,0x76, 0xFE,0xA1, 0xFE,0xC7, 0xFE,0xD9, 0xFE,0xF9, 0xFF,0x16, };

uchar code yinyue[]={0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0x00,0x00}; void delay1(uint z) {

uint x,y;

for(x=z;x>0;x--)

for(y=19000;y>0;y--); }

void delay2(uint z) {

uint x,y;

for(x=z;x>0;x--) for(y=110;y>0;y--); }

void song() {

uint temp; uchar aa; c=0; while(1) {

if(k1==0) {count2=1;} if(k2==0) {count2=2;} if(k3==0) {count2=3;} if(count2==0)

{break;}

if(count2==1) {temp=table1[c];} if(count2==2) {temp=table2[c];} if(count2==3) {temp=table3[c];} if(temp==0xff) {break;} aa=temp/16; if(aa!=0)

{a=qz[aa*2];b=qz[aa*2+1];} else

{TR1=0;BEEP=1;} delay1(temp);

TR1=0;BEEP=1;delay2(10);TR1=1;c++; }

TR1=0;BEEP=1; }

void write_com(uchar com) {

RS=0;RW=0;P0=com;E=1;delay2(5);E=0; }

void write_data(uchar date) {

RS=1;RW=0;E=0;P0=date;E=1;delay2(5);E=0; }

void key() {

if(k4==0)

{delay2(10);TR1=0;count2=0;c=0;} if(RS==1) {

write_com(0x01); write_com(0x80+0); write_data('W'); write_com(0x80+1); write_data('e'); write_com(0x80+2); write_data('1'); write_com(0x80+3);

搜索更多关于: 电子音乐盒的设计 的文档
电子音乐盒的设计.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c6sq3y0hwbv10e609m87w9sc9l3ppgr019uw_6.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top