|
驱动程序:
- #include<reg51.h>
- sbit Kp=P1^6;
- sbit Kn=P1^7;
- void main()
- {
- unsigned char i;
- unsigned int t;
- unsigned char r[8]={0xc5,0xc1,0xc9,0xc8,0xca,0xc2,0xc6,0xc4};
- P1=0xf0;
- while(1){
- if((Kp==0&Kn!=0)){
- for(i=0;i<8;i++){
- P1=(P1&0xf0)|r[i];
- for(t=0;t<10000;t++);}}
- else if((Kn==0&Kp!=0)){
- for(i=7;i<8;i--){
- P1=(P1&0xf0)|r[i];
- for(t=0;t<10000;t++);}}
- else P1&=0XF0;}
- }
复制代码 proteus仿真如下:
|
|