您的位置:首页 > 其它

74HC595扩展按键扫描---调试笔记

2013-01-20 08:45 225 查看
问题出现在了按键扫描过程中,使用延时,但是为什么使用延时就检测不到,还是没琢磨明白。

#include "hc595.h"

/*------------------------------------------------ 按键扫描程序 ------------------------------------------------*/

unsigned char keyscan(void) { unsigned char Val; SendByte(0x1b); LINE_SET;

if((P4&0x70)!=0x70) {

Val = P4&0x70; Val+=0x1b; while((P4&0x70)!=0x70); delay_10ms(1); while((P4&0x70)!=0x70); return Val;

} SendByte(0x17); LINE_SET;

if((P4&0x70)!=0x70) {

Val = P4&0x70; Val+=0x17; while((P4&0x70)!=0x70); delay_10ms(1); while((P4&0x70)!=0x70); return Val;

}

SendByte(0x0f); LINE_SET;

if((P4&0x70)!=0x70) {

Val = P4&0x70; Val+=0x0f; while((P4&0x70)!=0x70); delay_10ms(1); while((P4&0x70)!=0x70); return Val;

} SendByte(0x1d); LINE_SET;

if((P4&0x70)!=0x70) {

Val = P4&0x70; Val+=0x1d; while((P4&0x70)!=0x70); delay_10ms(1); while((P4&0x70)!=0x70); return Val;

} SendByte(0x1e); LINE_SET;

if((P4&0x70)!=0x70) {

Val = P4&0x70; Val+=0x1e; while((P4&0x70)!=0x70); delay_10ms(1); while((P4&0x70)!=0x70); return Val;

}

return 0xff; }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: