Skip to content

Instantly share code, notes, and snippets.

@ethanjli
Created April 14, 2016 02:23
Show Gist options
  • Save ethanjli/8b341c0c324529d731e78deb2bc4541a to your computer and use it in GitHub Desktop.
Save ethanjli/8b341c0c324529d731e78deb2bc4541a to your computer and use it in GitHub Desktop.
Pulse Sensor Arduino Sketch
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