查看AttachInterrupt()的源代碼
←
AttachInterrupt()
跳轉(zhuǎn)至:
導(dǎo)航
、
搜索
因為以下原因,你沒有權(quán)限編輯本頁:
您剛才請求的操作只有這個用戶組中的用戶才能使用:
用戶
您可以查看并復(fù)制此頁面的源代碼:
<pre style="color:blue"> void attachInterrupt (uint8_t interruptNum, void(*)(void)userFunc, int mode) </pre> 設(shè)置中斷 <br> 指定中斷函數(shù). 外部中斷有0和1兩種, 一般對應(yīng)2號和3號數(shù)字引腳.<br> 引腳說明(interruptNum):<br> Uno/Nano/Mega上<br> *中斷0腳就是D2 *中斷1腳就是D3 參數(shù):<br> *interrupt 中斷類型, 0或1 *fun 對應(yīng)函數(shù) *mode 觸發(fā)方式. 有以下幾種: **LOW 低電平觸發(fā)中斷 **CHANGE 變化時觸發(fā)中斷 **RISING 低電平變?yōu)楦唠娖接|發(fā)中斷 **FALLING 高電平變?yōu)榈碗娖接|發(fā)中斷 注解:<br> 在中斷函數(shù)中 delay 函數(shù)不能使用, millis 始終返回進入中斷前的值. 讀串口數(shù)據(jù)的話, 可能會丟失. 中斷函數(shù)中使用的變量需要定義為 volatile 類型.<br> 下面的例子如果通過外部引腳觸發(fā)中斷函數(shù), 然后控制LED的閃爍.<br> <pre style="color:green"> 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; } </pre>
返回
AttachInterrupt()
。
來自“
http://gharee.com/wiki/index.php/AttachInterrupt()
”
導(dǎo)航菜單
個人工具
登錄
名字空間
頁面
討論
變換
查看
閱讀
查看源代碼
查看歷史
操作
搜索
導(dǎo)航
首頁
社區(qū)專頁
新聞動態(tài)
最近更改
隨機頁面
工具箱
鏈入頁面
相關(guān)更改
特殊頁面
頁面信息
隱私政策
關(guān)于ALSROBOT WiKi
免責(zé)聲明