Skip to content

Instantly share code, notes, and snippets.

@mironal
Created August 15, 2012 21:41
#include <MsTimer2.h>
/* タイマ割り込み間隔 */
#define TIMER2_INTERVAL (unsigned long)500
#define LOCK 1
#define UNLOCK 0
volatile int lock = 0;
/* タイマ割り込み */
void timer2interrupt() {
lock = UNLOCK; /* ロック開放 */
}
void setup() {
Serial.begin(115200);
MsTimer2::set(TIMER2_INTERVAL, timer2interrupt);
MsTimer2::start();
}
void loop() {
if( lock == UNLOCK ){
/* 何か処理 */
lock = LOCK;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment