Interrupt for measuring time


hello guys,

i have tried find suitable had no luck far that's why approach since last hope :d

i have got electrical engine , want measure frequency runs. rotational meter creates rectangle current. want count how there rise in current , want measure time between 2 flanks.

but have no idea how overall structure looks like. can please me?

you can use interrupt triggered when pin goes low high (voltage) , then, measure time.

code: [select]

unsigned long lasttime;
unsigned long period;

void setup()
{
  attachinterrupt(0, measurefrec, rising);  // arduino pin 2
}

void measurefrec()
{
  unsigned long time;
 
  time = millis();  // beware overflow!!
  period = time - lasttime;
  lasttime = time;
}



Arduino Forum > Using Arduino > Programming Questions > Interrupt for measuring time


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

listen to event