18/03/03 20:15:02.24 9eQNWtE1.net
#include <DS3232RTC.h> //URLリンク(github.com)
#include <Streaming.h> //URLリンク(arduiniana.org)
#include <Time.h> //URLリンク(github.com)
#include <TimeLib.h> //URLリンク(github.com)
#include <Wire.h> //URLリンク(arduino.cc)
#define echoPin 8 // Echo Pin
volatile unsigned long timer1_overflow_count = 0;//volatile 割りこみ関数、メイン関数間で共有する時使用
volatile unsigned long pulse_count = 0;
volatile bool tgle_catch = true;
volatile bool wait = true;
ISR(TIMER1_OVF_vect)//timer1がオーバーフローした際に呼ばれる。オーバーフローまで4ms弱ある
{
timer1_overflow_count++;
}
ISR(TIMER1_CAPT_vect)
{
cli();//割りこみ禁止
pulse_count = ICR1;
if(tgle_catch){
digitalWrite(10, HIGH);TCCR1B = 0b00000001;//timer1 インプットキャプチャ立ち 下がり でON 分周比1 カウント開始
}else{
digitalWrite(9, HIGH);TCCR1B = 0b01000001;//timer1 インプットキャプチャ立ち上がりでON 分周比1 カウント開始
}tgle_catch = !tgle_catch;
wait = false;
sei();//割りこみ許可
}