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

问题出现在了按键扫描过程中,使用延时,但是为什么使用延时就检测不到,还是没琢磨明白。

#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; }

 

 

 

posted @ 2013-01-20 08:45  乡下菜农  阅读(2207)  评论(0编辑  收藏  举报