求助 中断函数
在网上看了写中断函数的例子,对attachInterrupt(0, 函数, LOW);语句中间的“函数”一直不会用,比如我想在下面写一个中断的for函数,这里attachInterrupt语句里的“函数”我需要写什么?程序的最开始需要申明这个函数吗?如何申明?这语句中的函数一般都是什么函数? 还有一个问题:我在 官网上摘抄一段 中断函数都会报错……是不是板子问题?attachInterrupt(0, blink, change);
提示是blink was not declared in this scope
求高手解答 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;
}更多关于中断的用法,参考这里:
http://arduino.cc/en/Reference/AttachInterrupt 谢谢先,不过我是复制的您那段程序啊,还是报错呢……就是提示是blink was not declared in this scope。
一直搞不懂是哪里出的问题~我的板子是买的淘宝教学套件,是不是少了什么程序才这样子? hustwhzl 发表于 2014-10-16 21:02 static/image/common/back.gif
谢谢先,不过我是复制的您那段程序啊,还是报错呢……就是提示是blink was not declared in this scope。
...
int pin = 13;
volatile int state = LOW;
void blink()
{
//中断函数中写你想做的操作,中断函数中的程序越简单越好。
state = !state;
}
void setup()
{
pinMode(pin, OUTPUT);
attachInterrupt(0, blink, CHANGE);
}
void loop()
{
digitalWrite(pin, state);
}
你的IDE的版本?
页:
[1]