標(biāo)題:
ARDUINO定時(shí)器中斷實(shí)驗(yàn)
[打印本頁(yè)]
作者:
S.H.M
時(shí)間:
2019-8-2 19:41
標(biāo)題:
ARDUINO定時(shí)器中斷實(shí)驗(yàn)
#include <MsTimer2.h> //定時(shí)器庫(kù)的 頭文件
int LED1=13;
int LED2=9;
void setup() {
// put your setup code here, to run once:
pinMode(LED1,OUTPUT);
pinMode(LED2,OUTPUT);
MsTimer2::set(500, dongzuo); // 中斷設(shè)置函數(shù),每 500ms 進(jìn)入一次中斷
MsTimer2::start(); //開(kāi)始計(jì)時(shí)
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED1,HIGH);
delay(1000);
digitalWrite(LED1,LOW);
delay(1000);
}
void dongzuo()
{
/*
static boolean out=HIGH;
digitalWrite(LED2,out);
out=!out;
*/
digitalWrite(LED2,HIGH);
delay(100);
digitalWrite(LED2,LOW);
delay(100);
}
作者:
tyrl800
時(shí)間:
2019-9-1 21:02
用TIMERONE庫(kù)更簡(jiǎn)單喲
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1