Created
April 14, 2016 02:23
-
-
Save ethanjli/8b341c0c324529d731e78deb2bc4541a to your computer and use it in GitHub Desktop.
Pulse Sensor Arduino Sketch
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
volatile unsigned long count = 0; | |
unsigned long oldcount = 0; | |
unsigned long last; | |
unsigned long freq = 0; | |
void irq1() | |
{ | |
count++; | |
} | |
void setup() | |
{ | |
Serial.begin(115200); | |
pinMode(7, INPUT); | |
attachInterrupt(digitalPinToInterrupt(7), irq1, RISING); | |
} | |
void loop() | |
{ | |
if (millis() - last >= 100) | |
{ | |
last = millis(); | |
Serial.println((count - oldcount) * 10); | |
oldcount = count; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment