unsigned char Trg;
unsigned char Cont;
void KeyRead( void )
{
unsigned char ReadData = PINB^0xff; // 1
Trg = ReadData & (ReadData ^ Cont); // 2
Cont = ReadData; // 3
}
固定是时间比如10ms-50ms扫描一次, 前提io要有滤波功能或者IOpin增加滤波电容, 否则某些KEY品质太差,会抖动.
unsigned char Trg;
unsigned char Cont;
void KeyRead( void )
{
unsigned char ReadData = PINB^0xff; // 1
Trg = ReadData & (ReadData ^ Cont); // 2
Cont = ReadData; // 3
}
固定是时间比如10ms-50ms扫描一次, 前提io要有滤波功能或者IOpin增加滤波电容, 否则某些KEY品质太差,会抖动.