I am programming Arduino to know the time between high to low or low to high. But i am getting constant values from timer interrupt value. It was 1246*10ms= 12460. What is wrong with this code. I am tracking my signal with oscilloscope. Actual time was an approximately 250ms. Help me please.
#include <TimerOne.h>
void setup(void)
{
pinMode(7, INPUT);
Timer1.initialize(100);//1000000=1s
Timer1.attachInterrupt(blinkLED);
Serial.begin(9600);
}
int ledState = LOW,T=0,state0=0,state1=0;
volatile unsigned long blinkCount = 0; variables
void blinkLED(void)
{
T++;
}
void loop(void)
{
state0=state1;
state1=digitalRead(7);
if(state0!=state1)
{
//Serial.print("state1=");
//Serial.print(state1);
//Serial.print(" T=");
Serial.println(T);
T=0;
}
}