Created
May 28, 2014 20:32
-
-
Save dwblair/b9c91c138396fee3932a to your computer and use it in GitHub Desktop.
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
//long pulseCount = 0; | |
unsigned long pulseTime,lastTime, duration; | |
void setup() | |
{ | |
Serial.begin(9600); | |
// KWH interrupt attached to IRQ 1 = pin3 | |
attachInterrupt(1, onPulse, FALLING); | |
} | |
void loop() | |
{ | |
} | |
void onPulse() | |
{ | |
//pulseCount++; | |
lastTime = pulseTime; | |
pulseTime = micros(); | |
duration=pulseTime-lastTime; | |
float durationS=duration/1000000.; | |
Serial.print("duration="); | |
Serial.println(durationS); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment