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

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

 

 

 

相关文章:

  • 2021-08-20
  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
猜你喜欢
  • 2021-12-08
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2021-12-26
  • 2021-08-04
  • 2022-12-23
相关资源
相似解决方案