电子琴C程序代码四乘四矩阵键盘输入.docx

上传人:b****3 文档编号:1920838 上传时间:2022-10-25 格式:DOCX 页数:8 大小:14.83KB
下载 相关 举报
电子琴C程序代码四乘四矩阵键盘输入.docx_第1页
第1页 / 共8页
电子琴C程序代码四乘四矩阵键盘输入.docx_第2页
第2页 / 共8页
电子琴C程序代码四乘四矩阵键盘输入.docx_第3页
第3页 / 共8页
电子琴C程序代码四乘四矩阵键盘输入.docx_第4页
第4页 / 共8页
电子琴C程序代码四乘四矩阵键盘输入.docx_第5页
第5页 / 共8页
点击查看更多>>
下载资源
资源描述

电子琴C程序代码四乘四矩阵键盘输入.docx

《电子琴C程序代码四乘四矩阵键盘输入.docx》由会员分享,可在线阅读,更多相关《电子琴C程序代码四乘四矩阵键盘输入.docx(8页珍藏版)》请在冰豆网上搜索。

电子琴C程序代码四乘四矩阵键盘输入.docx

电子琴C程序代码四乘四矩阵键盘输入

电子琴C程序代码,四乘四矩阵键盘输入

#include

#defineucharunsignedchar#defineuintunsignedint

sbitduan=P2^6;

sbitwei=P2^7;

sbitbee=P2^3;

ucharcodetable[]={

0x3f,0x06,0x5b,0x4f,

0x66,0x6d,0x7d,0x07,

0x7f,0x6f,0x77,0x7c,

0x39,0x5e,0x79,0x71};

ucharcodetablewe[]={

0x7f,0xbf,0xdf,0xef,

0xf7,0xfb,0xfd,0xfe};

uchardisp[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,

0x7f,0x6f,0x77,0x7c,

0x39,0x5e,0x79,0x71};//在里面输入按下键值为0~15对应要显示的第一位码值uchardisp1[16]={0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,

0x7f,0x6f,0x77,0x7c,

0x39,0x5e,0x79,0x71,0x3f};//在里面输入按下键值为0~15对应要显示的第二位码值unsignedchartemp;

unsignedcharkey;

unsignedchari,j;

unsignedcharSTH0;

unsignedcharSTL0;

unsignedintcodetab[]={

//63625,63833,64019,64104,64260,64400,64524,//低音区:

1234567

64580,64685,64778,64820,64898,64968,65030,//中音区:

1234567

65058,65110,65157,65178,65217,65252,65283,//高音区:

1234567

65297,//超高音:

1};//音调数据表可改

voiddelay(ucharx)

{

uchary,z;

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

for(z=0;z<110;z++);

}

voidinit()

{

TMOD=0x01;

ET0=1;

EA=1;

}

voiddisplay(){

for(i=0;i<2;i++)

{

P0=tablewe[i];

wei=1;

wei=0;

if(i==0)

P0=disp[key];

else

P0=disp1[key];

duan=1;

duan=0;

delay(4);

}

}

voidmain(void){

init();

while

(1)

{

P3=0xef;

temp=P3;

temp=temp&0x0f;

if(temp!

=0x0f)

{

delay(5);

temp=P3;

temp=temp&0x0f;

if(temp!

=0x0f)

{

temp=P3;

temp=temp&0x0f;

switch(temp)

{

case0x0e:

key=0;

break;

case0x0d:

key=1;

break;

case0x0b:

key=2;

break;

case0x07:

key=3;

break;

}

temp=P3;

STH0=tab[key]/256;

STL0=tab[key]%256;

TR0=1;

temp=temp&0x0f;

while(temp!

=0x0f)

{

display();

temp=P3;

temp=temp&0x0f;

}

}

}

P3=0xdf;

temp=P3;

temp=temp&0x0f;

if(temp!

=0x0f)

{

delay(5);

temp=P3;

temp=temp&0x0f;

if(temp!

=0x0f)

{

temp=P3;

temp=temp&0x0f;

switch(temp)

{

case0x0e:

key=4;

break;

case0x0d:

key=5;

break;

case0x0b:

key=6;

break;

case0x07:

key=7;

break;

}

temp=P3;

STH0=tab[key]/256;

STL0=tab[key]%256;

TR0=1;

temp=temp&0x0f;

while(temp!

=0x0f)

{

display();

temp=P3;

temp=temp&0x0f;

}

}

}

P3=0xbf;

temp=P3;

temp=temp&0x0f;

if(temp!

=0x0f)

{

delay(5);

temp=P3;

temp=temp&0x0f;

if(temp!

=0x0f)

{

temp=P3;

temp=temp&0x0f;

switch(temp)

{

case0x0e:

key=8;

break;

case0x0d:

key=9;

break;

case0x0b:

key=10;

break;

case0x07:

key=11;

break;

}

temp=P3;

STH0=tab[key]/256;

STL0=tab[key]%256;

TR0=1;

temp=temp&0x0f;

while(temp!

=0x0f)

{

display();

temp=P3;

temp=temp&0x0f;

}

}

}

P3=0x7f;

temp=P3;

temp=temp&0x0f;

if(temp!

=0x0f)

{

delay(5);

temp=P3;

temp=temp&0x0f;

if(temp!

=0x0f)

{

temp=P3;

temp=temp&0x0f;

switch(temp)

{

case0x0e:

key=12;

break;

case0x0d:

key=13;

break;

case0x0b:

key=14;

break;

case0x07:

key=15;

break;

}

temp=P3;

STH0=tab[key]/256;

STL0=tab[key]%256;

TR0=1;

temp=temp&0x0f;

while(temp!

=0x0f)

{

display();

temp=P3;

temp=temp&0x0f;

}

}

}

bee=1;

TR0=0;

display();

}

}

voidt0(void)interrupt1using0

{

TH0=STH0;

TL0=STL0;

bee=~bee;

}

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

当前位置:首页 > PPT模板 > 商务科技

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

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