|
本帖最后由 BLACKBLUE 于 2021-11-20 16:10 编辑
#include <PinChangeInt.h>
uint32_t xxx_ ISR_time;
bool LED_BUILTIN_state ;
......
void setup(){
pinMode(xxx_pin, INPUT_PULLUP); //内部上拉,按下是低电平
pinMode(yyy_pin, INPUT); //悬空或者有物理下拉,按下高电平
digitalWrite(yyy_pin, LOW); //确定初始态
attachPinChangeInterrupt(xxx_pin,xxx_fun, FALLING); //
attachPinChangeInterrupt(yyy_pin,yyy_fun, RISING);
.....
}
void loop(){
digitalWrite(LED_BUILTIN,LED_BUILTIN_state);
}
void xxx_fun() {
if (millis() - xxx_ISR_time > 200)
{
xxx_ ISR_time = millis();
LED_BUILTIN_state = true; }
}
.....
|
|