完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
这是我在这论坛找的电子琴资料,有原理图和程序,但是我不知道我的按键键盘8个脚,应该分别连着单片机哪8个脚。希望有人看出来能告诉我,新手在此万分感谢......
#include #include typedef unsigned char uchar; typedef unsigned int uint; uchar code table[]={0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71}; uchar temp; uchar key; uchar i,j; uchar STH0; uchar STL0; uint code tab[]={64021,64103,64260,64400, 64524,64580,64684,64777, 64820,64898,64968,65030, 65058,65110,65157,65178}; void main(void) { TMOD=0x01; ET0=1; EA=1; while(1) { P3=0xff; P3_4=0; temp=P3; temp=temp & 0x0f; if (temp!=0x0f) { for(i=50;i>0;i--) for(j=200;j>0;j--); temp=P3; temp=temp & 0x0f; if (temp!=0x0f) { temp=P3; temp=temp & 0x0f; switch(temp) { case 0x0e: key=0; break; case 0x0d: key=1; break; case 0x0b: key=2; break; case 0x07: key=3; break; } temp=P3; P1_0=~P1_0; P0=table[key]; STH0=tab[key]/256; STL0=tab[key]%256; TR0=1; temp=temp & 0x0f; while(temp!=0x0f) { temp=P3; temp=temp & 0x0f; } TR0=0; } } P3=0xff; P3_5=0; temp=P3; temp=temp & 0x0f; if (temp!=0x0f) { for(i=50;i>0;i--) for(j=200;j>0;j--); temp=P3; temp=temp & 0x0f; if (temp!=0x0f) { temp=P3; temp=temp & 0x0f; switch(temp) { case 0x0e: key=4; break; case 0x0d: key=5; break; case 0x0b: key=6; break; case 0x07: key=7; break; } temp=P3; P1_0=~P1_0; P0=table[key]; STH0=tab[key]/256; STL0=tab[key]%256; TR0=1; temp=temp & 0x0f; while(temp!=0x0f) { temp=P3; temp=temp & 0x0f; } TR0=0; } } P3=0xff; P3_6=0; temp=P3; temp=temp & 0x0f; if (temp!=0x0f) { for(i=50;i>0;i--) for(j=200;j>0;j--); temp=P3; temp=temp & 0x0f; if (temp!=0x0f) { temp=P3; temp=temp & 0x0f; switch(temp) { case 0x0e: key=8; break; case 0x0d: key=9; break; case 0x0b: key=10; break; case 0x07: key=11; break; } temp=P3; P1_0=~P1_0; P0=table[key]; STH0=tab[key]/256; STL0=tab[key]%256; TR0=1; temp=temp & 0x0f; while(temp!=0x0f) { temp=P3; temp=temp & 0x0f; } TR0=0; } } P3=0xff; P3_7=0; temp=P3; temp=temp & 0x0f; if (temp!=0x0f) { for(i=50;i>0;i--) for(j=200;j>0;j--); temp=P3; temp=temp & 0x0f; if (temp!=0x0f) { temp=P3; temp=temp & 0x0f; switch(temp) { case 0x0e: key=12; break; case 0x0d: key=13; break; case 0x0b: key=14; break; case 0x07: key=15; break; } temp=P3; P1_0=~P1_0; P0=table[key]; STH0=tab[key]/256; STL0=tab[key]%256; TR0=1; temp=temp & 0x0f; while(temp!=0x0f) { temp=P3; temp=temp & 0x0f; } TR0=0; } } } } void t0(void) interrupt 1 using 0 { TH0=STH0; TL0=STL0; P1_0=~P1_0; } |
|
相关推荐
7个回答
|
|
|
应该是p3的8个脚
|
|
|
|
|
|
|
|
|
|
|
|
你好,首先谢谢你的回答。我还想请教一下,可不可以看出来1~8分别对应着什么P3.0~P3.7,是倒序对应还是顺序对应,还是怎样?我刚刚试了一下,结果不稳定,很乱,貌似不是1~8顺序对应P3.0~P3.7,谢谢。 |
|
|
|
|
|
这个是矩形键盘,原理图标明了1234等脚,你就用p3^0对应1脚,p3^1对应2脚,以此类推,试试 |
|
|
|
|
|
图上已经标明了啊
|
|
|
|
|
|
按顺序接P3.0-P3.7
|
|
|
|
|
|
P3.0-P3.3都是按钮
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
528 浏览 0 评论
654 浏览 0 评论
858 浏览 0 评论
837 浏览 0 评论
RT-Thread与英飞凌(infineon)合作得板子PSOC 6 板子学习
770 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
17060 浏览 31 评论
浏览过的版块 |
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-14 12:38 , Processed in 1.015997 second(s), Total 84, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
7572