友情提示:380元/半年,儿童学编程,就上码丁实验室。
arduino
你将学到什么
你将学到arduino uno的中断功能
中断介绍
中断
中断模式
设置中断
在setup()中使用函数
attachInterrupt(0,function,mode);
attachInterrupt(1,function,mode);
这里,0对应数字针脚2,1对应数字针脚3;
案例
在arduino数字3号针脚连接了一个按钮。
arduino代码:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
attachInterrupt(1,myFun,RISING);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(“hello”);
delay(200);
}
void myFun()
{
Serial.println(“—”);
}
串口监视器:
串口显示
欢迎转发评论!