attachInterrupt(interrupt, function, mode)
当发生外部中断时,调用一个指定函数。
参数
注意事项
使用中断
程序示例
int pin = 13;
volatile int state = LOW;
void setup()
{
pinMode(pin, OUTPUT);
attachInterrupt(0, blink, CHANGE);
}
void loop()
{
digitalWrite(pin, state);
}
void blink()
{
state = !state;
}最后更新于