//定义全局变量
int flag = 0;
boolean _up = false;

//下面的程序放在loop()里
if(digitalRead(digitalPin) == LOW)
flag = 1;
if((digitalRead(digitalPin) == HIGH) && (flag == 1))
{
_up = true; flag = 0;
}

if(_up)
{
_up = false;
//这里写希望检测到上升沿后执行的程序

}

Last modification:October 18th, 2018 at 04:45 pm