如何使用 RISING 和 FALLING 边沿进行 Arduino attachInterrupt()
你可以使用 attachInterupt() 和 CHANGE 在 RISING 和 FALLING 边沿都触发。
attachinterrupt_change_arduino.cpp
#define INTERRUPT_PIN 13 // 在此处选择任何具有中断功能的引脚。
void myInterrupt() {
// TODO 你的代码放在这里。
}
void setup() {
attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), myInterrupt, CHANGE);
}If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow