《基于protues矩阵键盘c程序》由会员分享,可在线阅读,更多相关《基于protues矩阵键盘c程序(3页珍藏版)》请在金锄头文库上搜索。
1、#include #define keyp P1 #define uchar unsigned char sbit p20=P20; sbit p21=P21; sbit p22=P22; sbit p23=P23; sbit p24=P24; sbit p25=P25; sbit p26=P26; sbit p27=P27; sbit p30=P30; sbit p31=P31; sbit p32=P32; sbit p33=P33; sbit p34=P34; sbit p35=P35; sbit p36=P36; sbit p37=P37; unsigned char keyv=0xff
2、; uchar keys(void); void keyaa(void); void delay(int n) int i,j; for(i=0;in;i+) for(j=0;j100;j+); void main(void) keyv=0xff; do if(keyv!=0xff) keyaa(); keyv=0xff; keyv=keys(); while(1); uchar keys(void)uchar readk,rereadk;uchar xtemp,ytemp;keyp=0x0f;xtemp=keypif(xtemp=0x0f)return (0xff);keyp=0xf0;yt
3、emp=keypreadk=xtemp|ytemp; delay(10);keyp=0x0f;xtemp=keypif(xtemp=0x0f)return (0xff);keyp=0xf0;ytemp=keyprereadk=xtemp|ytemp;if(readk=rereadk)return(rereadk); return(0xff); void keyaa(void) switch(keyv) case 0x11: p20=0;delay(50);p20=1; break; case 0x21: p21=0; break; case 0x41: p22=0; break; case 0
4、x81: p23=0; break; /第一行、 、case 0x12: p24=0; break; case 0x22: p25=0; break; case 0x42: p26=0; break; case 0x82: p27=0; break; /第二行、 、case 0x14: p30=0; break; case 0x24: p31=0; break; case 0x44: p32=0; break; case 0x84: p33=0; break; /第三行、 、case 0x18: p34=0; break; case 0x28: p35=0; break; case 0x48: p36=0; break; case 0x88: p37=0; break; /第四行、 、default:break;