arduino入门(三)

arduino的中断使用 attachinterrupt函数

attachInterrupt语句语法

attachInterrupt(digitalPinToInterrupt(pin),ISR,mode);//recommended for arduino board
attachInterrupt(pin, ISR, mode) ; //recommended Arduino Due, Zero only
//pin: 引脚号
//argument ISR: 中断事件; ISR是一个函数,比如blink.
  
//argument mode:何时触发中断.

以下三个常量被预定义为有效值:

该函数有三个参数,放在setup代码块里面

void setup() {
   pinMode(13, OUTPUT); //set pin 13 as output
   attachInterrupt(digitalPinToInterrupt(pin), blink, CHANGE);
   //interrupt at pin 2 blink ISR when pin to change the value
} 


arduino有串行和并行通信

一下是uart协议,使用serial

void setup() {
   Serial.begin(9600); //set up serial library baud rate to 9600
   Serial.println("hello world"); //print hello world
}

void loop() {

}
展开阅读全文

页面更新:2024-03-11

标签:有效值   常量   语句   语法   函数   入门   协议   参数   事件   代码   通信   体育

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top