Created
August 15, 2012 21:41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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