单片机开发按键去抖原因
例如:
#include <ioCC2530.h>
#define Key1 P1_2
void DelayMs(unsigned int duration)
{
unsigned int i, j;
for(i = 0; i < duration; i++)
for(j = 0; j < 535; j++){}
}
void main(void)
{
if(Key1 == 0)
{
DelayMs(10);
if(Key1 == 0){
//Running the task.
}
}
}