[
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Pulse Sensor\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n"
  },
  {
    "path": "PulseSensorAmped_Arduino_1.5.0/AllSerialHandling.ino",
    "content": "\n//////////\n/////////  All Serial Handling Code,\n/////////  It's Changeable with the 'outputType' variable\n/////////  It's declared at start of code.\n/////////\n\nvoid serialOutput(){   // Decide How To Output Serial.\n  switch(outputType){\n    case PROCESSING_VISUALIZER:\n      sendDataToSerial('S', Signal);     // goes to sendDataToSerial function\n      break;\n    case SERIAL_PLOTTER:  // open the Arduino Serial Plotter to visualize these data\n      Serial.print(BPM);\n      Serial.print(\",\");\n      Serial.print(IBI);\n      Serial.print(\",\");\n      Serial.println(Signal);\n      break;\n    default:\n      break;\n  }\n\n}\n\n//  Decides How To OutPut BPM and IBI Data\nvoid serialOutputWhenBeatHappens(){\n  switch(outputType){\n    case PROCESSING_VISUALIZER:    // find it here https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer\n      sendDataToSerial('B',BPM);   // send heart rate with a 'B' prefix\n      sendDataToSerial('Q',IBI);   // send time between beats with a 'Q' prefix\n      break;\n\n    default:\n      break;\n  }\n}\n\n//  Sends Data to Pulse Sensor Processing App, Native Mac App, or Third-party Serial Readers.\nvoid sendDataToSerial(char symbol, int data ){\n    Serial.print(symbol);\n    Serial.println(data);\n  }\n"
  },
  {
    "path": "PulseSensorAmped_Arduino_1.5.0/Interrupt.ino",
    "content": "\n\n\nvolatile int rate[10];                    // array to hold last ten IBI values\nvolatile unsigned long sampleCounter = 0;          // used to determine pulse timing\nvolatile unsigned long lastBeatTime = 0;           // used to find IBI\nvolatile int P =512;                      // used to find peak in pulse wave, seeded\nvolatile int T = 512;                     // used to find trough in pulse wave, seeded\nvolatile int thresh = 530;                // used to find instant moment of heart beat, seeded\nvolatile int amp = 0;                   // used to hold amplitude of pulse waveform, seeded\nvolatile boolean firstBeat = true;        // used to seed rate array so we startup with reasonable BPM\nvolatile boolean secondBeat = false;      // used to seed rate array so we startup with reasonable BPM\n\n\nvoid interruptSetup(){  // CHECK OUT THE Timer_Interrupt_Notes TAB FOR MORE ON INTERRUPTS \n  // Initializes Timer2 to throw an interrupt every 2mS.\n  TCCR2A = 0x02;     // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE\n  TCCR2B = 0x06;     // DON'T FORCE COMPARE, 256 PRESCALER\n  OCR2A = 0X7C;      // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE\n  TIMSK2 = 0x02;     // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A\n  sei();             // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED\n}\n\n\n// THIS IS THE TIMER 2 INTERRUPT SERVICE ROUTINE.\n// Timer 2 makes sure that we take a reading every 2 miliseconds\nISR(TIMER2_COMPA_vect){                         // triggered when Timer2 counts to 124\n  cli();                                      // disable interrupts while we do this\n  Signal = analogRead(pulsePin);              // read the Pulse Sensor\n  sampleCounter += 2;                         // keep track of the time in mS with this variable\n  int N = sampleCounter - lastBeatTime;       // monitor the time since the last beat to avoid noise\n\n    //  find the peak and trough of the pulse wave\n  if(Signal < thresh && N > (IBI/5)*3){       // avoid dichrotic noise by waiting 3/5 of last IBI\n    if (Signal < T){                        // T is the trough\n      T = Signal;                         // keep track of lowest point in pulse wave\n    }\n  }\n\n  if(Signal > thresh && Signal > P){          // thresh condition helps avoid noise\n    P = Signal;                             // P is the peak\n  }                                        // keep track of highest point in pulse wave\n\n  //  NOW IT'S TIME TO LOOK FOR THE HEART BEAT\n  // signal surges up in value every time there is a pulse\n  if (N > 250){                                   // avoid high frequency noise\n    if ( (Signal > thresh) && (Pulse == false) && (N > (IBI/5)*3) ){\n      Pulse = true;                               // set the Pulse flag when we think there is a pulse\n      digitalWrite(blinkPin,HIGH);                // turn on pin 13 LED\n      IBI = sampleCounter - lastBeatTime;         // measure time between beats in mS\n      lastBeatTime = sampleCounter;               // keep track of time for next pulse\n\n      if(secondBeat){                        // if this is the second beat, if secondBeat == TRUE\n        secondBeat = false;                  // clear secondBeat flag\n        for(int i=0; i<=9; i++){             // seed the running total to get a realisitic BPM at startup\n          rate[i] = IBI;\n        }\n      }\n\n      if(firstBeat){                         // if it's the first time we found a beat, if firstBeat == TRUE\n        firstBeat = false;                   // clear firstBeat flag\n        secondBeat = true;                   // set the second beat flag\n        sei();                               // enable interrupts again\n        return;                              // IBI value is unreliable so discard it\n      }\n\n\n      // keep a running total of the last 10 IBI values\n      word runningTotal = 0;                  // clear the runningTotal variable\n\n      for(int i=0; i<=8; i++){                // shift data in the rate array\n        rate[i] = rate[i+1];                  // and drop the oldest IBI value\n        runningTotal += rate[i];              // add up the 9 oldest IBI values\n      }\n\n      rate[9] = IBI;                          // add the latest IBI to the rate array\n      runningTotal += rate[9];                // add the latest IBI to runningTotal\n      runningTotal /= 10;                     // average the last 10 IBI values\n      BPM = 60000/runningTotal;               // how many beats can fit into a minute? that's BPM!\n      QS = true;                              // set Quantified Self flag\n      // QS FLAG IS NOT CLEARED INSIDE THIS ISR\n    }\n  }\n\n  if (Signal < thresh && Pulse == true){   // when the values are going down, the beat is over\n    digitalWrite(blinkPin,LOW);            // turn off pin 13 LED\n    Pulse = false;                         // reset the Pulse flag so we can do it again\n    amp = P - T;                           // get amplitude of the pulse wave\n    thresh = amp/2 + T;                    // set thresh at 50% of the amplitude\n    P = thresh;                            // reset these for next time\n    T = thresh;\n  }\n\n  if (N > 2500){                           // if 2.5 seconds go by without a beat\n    thresh = 530;                          // set thresh default\n    P = 512;                               // set P default\n    T = 512;                               // set T default\n    lastBeatTime = sampleCounter;          // bring the lastBeatTime up to date\n    firstBeat = true;                      // set these to avoid noise\n    secondBeat = false;                    // when we get the heartbeat back\n  }\n\n  sei();                                   // enable interrupts when youre done!\n}// end isr\n"
  },
  {
    "path": "PulseSensorAmped_Arduino_1.5.0/PulseSensorAmped_Arduino_1.5.0.ino",
    "content": "\n/*  Pulse Sensor Amped 1.5    by Joel Murphy and Yury Gitman   http://www.pulsesensor.com\n\n----------------------  Notes ----------------------  ----------------------\nThis code:\n1) Blinks an LED to User's Live Heartbeat   PIN 13\n2) Fades an LED to User's Live HeartBeat    PIN 5\n3) Determines BPM\n4) Prints All of the Above to Serial\n\nRead Me:\nhttps://github.com/WorldFamousElectronics/PulseSensor_Amped_Arduino/blob/master/README.md\n ----------------------       ----------------------  ----------------------\n*/\n\n#define PROCESSING_VISUALIZER 1\n#define SERIAL_PLOTTER  2\n\n//  Variables\nint pulsePin = 0;                 // Pulse Sensor purple wire connected to analog pin 0\nint blinkPin = 13;                // pin to blink led at each beat\nint fadePin = 5;                  // pin to do fancy classy fading blink at each beat\nint fadeRate = 0;                 // used to fade LED on with PWM on fadePin\n\n// Volatile Variables, used in the interrupt service routine!\nvolatile int BPM;                   // int that holds raw Analog in 0. updated every 2mS\nvolatile int Signal;                // holds the incoming raw data\nvolatile int IBI = 600;             // int that holds the time interval between beats! Must be seeded!\nvolatile boolean Pulse = false;     // \"True\" when User's live heartbeat is detected. \"False\" when not a \"live beat\".\nvolatile boolean QS = false;        // becomes true when Arduoino finds a beat.\n\n// SET THE SERIAL OUTPUT TYPE TO YOUR NEEDS\n// PROCESSING_VISUALIZER works with Pulse Sensor Processing Visualizer\n//      https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer\n// SERIAL_PLOTTER outputs sensor data for viewing with the Arduino Serial Plotter\n//      run the Serial Plotter at 115200 baud: Tools/Serial Plotter or Command+L\nstatic int outputType = SERIAL_PLOTTER;\n\n\nvoid setup(){\n  pinMode(blinkPin,OUTPUT);         // pin that will blink to your heartbeat!\n  pinMode(fadePin,OUTPUT);          // pin that will fade to your heartbeat!\n  Serial.begin(115200);             // we agree to talk fast!\n  interruptSetup();                 // sets up to read Pulse Sensor signal every 2mS\n   // IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE,\n   // UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN\n//   analogReference(EXTERNAL);\n}\n\n\n//  Where the Magic Happens\nvoid loop(){\n\n    serialOutput() ;\n\n  if (QS == true){     // A Heartbeat Was Found\n                       // BPM and IBI have been Determined\n                       // Quantified Self \"QS\" true when arduino finds a heartbeat\n        fadeRate = 255;         // Makes the LED Fade Effect Happen\n                                // Set 'fadeRate' Variable to 255 to fade LED with pulse\n        serialOutputWhenBeatHappens();   // A Beat Happened, Output that to serial.\n        QS = false;                      // reset the Quantified Self flag for next time\n  }\n\n  ledFadeToBeat();                      // Makes the LED Fade Effect Happen\n  delay(20);                             //  take a break\n}\n\n\n\n\n\nvoid ledFadeToBeat(){\n    fadeRate -= 15;                         //  set LED fade value\n    fadeRate = constrain(fadeRate,0,255);   //  keep LED fade value from going into negative numbers!\n    analogWrite(fadePin,fadeRate);          //  fade LED\n  }\n"
  },
  {
    "path": "PulseSensorAmped_Arduino_1.5.0/Timer_Interrupt_Notes.ino",
    "content": "/*\n  These notes put together by Joel Murphy for Pulse Sensor Amped, 2015\n  The code that this section is attached to uses a timer interrupt\n  to sample the Pulse Sensor with consistent and regular timing.\n  The code is setup to read Pulse Sensor signal at 500Hz (every 2mS).\n  The reasoning for this can be found here:\n  http://pulsesensor.com/pages/pulse-sensor-amped-arduino-v1dot1\n\n  There are issues with using different timers to control the Pulse Sensor sample rate.\n  Sometimes, user will need to switch timers for access to other code libraries.\n  Also, some other hardware may have different timer setup requirements. This page\n  will cover those different needs and reveal the necessary settings. There are two\n  part of the code that will be discussed. The interruptSetup() routine, and\n  the interrupt function call. Depending on your needs, or the Arduino variant that you use,\n  check below for the correct settings.\n\n\n  ******************************************************************************************\n  ARDUINO UNO, Pro 328-5V/16MHZ, Pro-Mini 328-5V/16MHz (or any board with ATmega328P running at 16MHz)\n\n >> Timer2\n\n    Pulse Sensor Arduino UNO uses Timer2 by default.\n    Use of Timer2 interferes with PWM on pins 3 and 11.\n    There is also a conflict with the Tone library, so if you want tones, use Timer1 below.\n\n      void interruptSetup(){\n        // Initializes Timer2 to throw an interrupt every 2mS.\n        TCCR2A = 0x02;     // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE\n        TCCR2B = 0x06;     // DON'T FORCE COMPARE, 256 PRESCALER\n        OCR2A = 0X7C;      // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE\n        TIMSK2 = 0x02;     // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A\n        sei();             // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED\n      }\n\n    use the following interrupt vector with Timer2\n\n      ISR(TIMER2_COMPA_vect)\n\n >> Timer1\n\n    Use of Timer1 interferes with PWM on pins 9 and 10.\n    The Servo library also uses Timer1, so if you want servos, use Timer2 above.\n\n      void interruptSetup(){\n        // Initializes Timer1 to throw an interrupt every 2mS.\n        TCCR1A = 0x00; // DISABLE OUTPUTS AND PWM ON DIGITAL PINS 9 & 10\n        TCCR1B = 0x11; // GO INTO 'PHASE AND FREQUENCY CORRECT' MODE, NO PRESCALER\n        TCCR1C = 0x00; // DON'T FORCE COMPARE\n        TIMSK1 = 0x01; // ENABLE OVERFLOW INTERRUPT (TOIE1)\n        ICR1 = 16000;  // TRIGGER TIMER INTERRUPT EVERY 2mS\n        sei();         // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED\n      }\n\n    Use the following ISR vector for the Timer1 setup above\n\n      ISR(TIMER1_OVF_vect)\n\n >> Timer0\n\n    DON'T USE TIMER0! Timer0 is used for counting delay(), millis(), and micros().\n                      MESSING WITH Timer0 IS HIGHLY UNADVISED!\n\n  ******************************************************************************************\n  ARDUINO Fio, Lilypad, ProMini328-3V/8MHz (or any board with ATmega328P running at 8MHz)\n\n  >> Timer2\n\n    Pulse Sensor Arduino UNO uses Timer2 by default.\n    Use of Timer2 interferes with PWM on pins 3 and 11.\n    There is also a conflict with the Tone library, so if you want tones, use Timer1 below.\n\n      void interruptSetup(){\n        // Initializes Timer2 to throw an interrupt every 2mS.\n        TCCR2A = 0x02;     // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE\n        TCCR2B = 0x05;     // DON'T FORCE COMPARE, 128 PRESCALER\n        OCR2A = 0X7C;      // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE\n        TIMSK2 = 0x02;     // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A\n        sei();             // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED\n      }\n\n    use the following interrupt vector with Timer2\n\n      ISR(TIMER2_COMPA_vect)\n\n >> Timer1\n\n    Use of Timer1 interferes with PWM on pins 9 and 10.\n    The Servo library also uses Timer1, so if you want servos, use Timer2 above.\n\n      void interruptSetup(){\n        // Initializes Timer1 to throw an interrupt every 2mS.\n        TCCR1A = 0x00; // DISABLE OUTPUTS AND PWM ON DIGITAL PINS 9 & 10\n        TCCR1B = 0x11; // GO INTO 'PHASE AND FREQUENCY CORRECT' MODE, NO PRESCALER\n        TCCR1C = 0x00; // DON'T FORCE COMPARE\n        TIMSK1 = 0x01; // ENABLE OVERFLOW INTERRUPT (TOIE1)\n        ICR1 = 8000;  // TRIGGER TIMER INTERRUPT EVERY 2mS\n        sei();         // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED\n      }\n\n    Use the following ISR vector for the Timer1 setup above\n\n      ISR(TIMER1_OVF_vect)\n\n >> Timer0\n\n    DON'T USE TIMER0! Timer0 is used for counting delay(), millis(), and micros().\n                      MESSING WITH Timer0 IS HIGHLY UNADVISED!\n\n\n  ******************************************************************************************\n  ARDUINO Leonardo (or any board with ATmega32u4 running at 16MHz)\n\n  >> Timer1\n\n    Use of Timer1 interferes with PWM on pins 9 and 10.\n\n      void interruptSetup(){\n          TCCR1A = 0x00;\n          TCCR1B = 0x0C; // prescaler = 256\n          OCR1A = 0x7C;  // count to 124\n          TIMSK1 = 0x02;\n          sei();\n      }\n\n  The only other thing you will need is the correct ISR vector in the next step.\n\n      ISR(TIMER1_COMPA_vect)\n\n\n  ******************************************************************************************\n  ADAFRUIT Flora, ARDUINO Fio v3 (or any other board with ATmega32u4 running at 8MHz)\n\n  >> Timer1\n\n    Use of Timer1 interferes with PWM on pins 9 and 10.\n\n      void interruptSetup(){\n          TCCR1A = 0x00;\n          TCCR1B = 0x0C; // prescaler = 256\n          OCR1A = 0x3E;  // count to 62\n          TIMSK1 = 0x02;\n          sei();\n      }\n\n  The only other thing you will need is the correct ISR vector in the next step.\n\n      ISR(TIMER1_COMPA_vect)\n  ******************************************************************************************\n  ADAFRUIT Gemma, ADAFRUIT Trinket 8MHz, Digispark Pro 8MHz, (or any other board with ATtiny85 running at 8MHz)\n\n    NOTE: Gemma does not do serial communication! Comment out or remove the Serial code in the Arduino sketch!\n    \n    NOTE: You must use Software Serial with the Trinket or Digispark! \n          A the top of the main code page put these lines\n          \n            #define rxPin 3\n            #define txPin 4\n            SoftwareSerial uart(rxPin, txPin);\n\n          Then, whenever the word 'Serial' is used, replace it with 'uart'\n            example:\n              change Serial.begin(115200); to uart.begin(57600);\n            \n    NOTE: Use pin 2 to connect the Pulse Sensor Purple Pin on Trinket and Gemma!\n\n  Timer1\n\n    Use of Timer1 breaks PWM output on pin D1\n\n      void interruptSetup(){\n        TCCR1 = 0x88;      // Clear Timer on Compare, Set Prescaler to 128 TEST VALUE\n        GTCCR &= 0x81;     // Disable PWM, don't connect pins to events\n        OCR1C = 0x7C;      // Set the top of the count to  124 TEST VALUE\n        OCR1A = 0x7C;      // Set the timer to interrupt after counting to TEST VALUE\n        bitSet(TIMSK,6);   // Enable interrupt on match between TCNT1 and OCR1A\n        sei();             // Enable global interrupts\n      }\n    The only other thing you will need is the correct ISR vector in the next step.\n\n      ISR(TIMER1_COMPA_vect)\n\n  ******************************************************************************************\n  ADAFRUIT Trinket with 16MHz software setting, Digispark Pro 16MHz, (or any other board with ATtiny85 running at 16MHz)\n\n    NOTE: Use analog pin 2 for the Pulse Sensor purple wire.\n    \n    NOTE: You must use Software Serial with the Trinket or Digispark! \n          A the top of the main code page put these lines\n          \n            #define rxPin 3\n            #define txPin 4\n            SoftwareSerial uart(rxPin, txPin);\n\n          Then, whenever the word 'Serial' is used, replace it with 'uart'\n            example:\n              change Serial.begin(115200); to uart.begin(57600);\n\n  Timer1\n\n    Use of Timer1 breaks PWM output on pin D1\n\n      void interruptSetup(){\n        TCCR1 = 0x89;      // Clear Timer on Compare, Set Prescaler to 256\n        GTCCR &= 0x81;     // Disable PWM, don't connect pins to events\n        OCR1C = 0x7C;      // Set the top of the count to  124\n        OCR1A = 0x7C;      // Set the timer to interrupt after counting to 124\n        bitSet(TIMSK,6);   // Enable interrupt on match between TCNT1 and OCR1A\n        sei();             // Enable global interrupts\n      }\n    The only other thing you will need is the correct ISR vector in the next step.\n\n      ISR(TIMER1_COMPA_vect)\n      \n  ******************************************************************************************\n\n  IF YOU DON'T SEE THE MICROCONTROLLER YOU ARE USING, BUT YOU WANT A QUICK AND DIRTY SOLUTION\n\n  So many new micros are coming out that it's kind of mind boggling. We will add to this list with\n  code that uses interupts when we can, but if your micro is not listed here, and you are not willing\n  or able to grab a hardware timer yourself, here is a shortcut that will work.\n  It won't have the tight timing of a hardware interrupt, but it just might be good enough.\n  We are calling this the 'Software Interrupt' version.\n  The code below will set up a microsecond timer and 'trigger' every 2mS (or so).\n  \n  FIRST:\n  You will need to change the name of the funcion in the Interrupts tab from\n  'ISR(TIMER2_COMPA_vect)'\n  to\n  'void getPulse()'\n  \n  THEN:\n  Comment out the entire interruptSetup() function in the interrupts tab in order for this to work.\n  \n  USE:\n  The code example below. Notice that we are using the micros() and the millis() to time the sample rate and the fade rate.\n  DO NOT put any delays in the loop, or it will break the sample timing!\n\n  Happy Hacking!\n\n\n\n  // FIRST, CREATE VARIABLES TO PERFORM THE SAMPLE TIMING AND LED FADE FUNCTIONS\n  unsigned long lastTime; // used to time the Pulse Sensor samples\n  unsigned long thisTime; // used to time the Pulse Sensor samples\n  unsigned long fadeTime; // used to time the LED fade\n  \n  void setup(){\n    pinMode(blinkPin,OUTPUT);         // pin that will blink to your heartbeat!\n    pinMode(fadePin,OUTPUT);          // pin that will fade to your heartbeat!\n    Serial.begin(115200);             // we agree to talk fast!\n    // ADD THIS LINE IN PLACE OF THE interruptSetup() CALL\n    lastTime = micros();              // get the time so we can create a software 'interrupt'\n    // IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE,\n    // UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN\n    //   analogReference(EXTERNAL);\n  } //end of setup()\n\n  //IN THE LOOP, ADD THE CODE THAT WILL DO THE 2mS TIMING, AND CALL THE getPulse() FUNCTION.\n  void loop(){\n\n    serialOutput() ;\n\n    thisTime = micros();            // GET THE CURRENT TIME\n    if(thisTime - lastTime > 2000){ // CHECK TO SEE IF 2mS HAS PASSED\n      lastTime = thisTime;          // KEEP TRACK FOR NEXT TIME\n      getPulse();                   //CHANGE 'ISR(TIMER2_COMPA_vect)' TO 'getPulse()' IN THE INTERRUPTS TAB!\n    }\n\n  if (QS == true){     // A Heartbeat Was Found\n                       // BPM and IBI have been Determined\n                       // Quantified Self \"QS\" true when arduino finds a heartbeat\n        fadeRate = 255;         // Makes the LED Fade Effect Happen\n                                // Set 'fadeRate' Variable to 255 to fade LED with pulse\n        fadeTime = millis();    // Set the fade timer to fade the LED\n        serialOutputWhenBeatHappens();   // A Beat Happened, Output that to serial.\n        QS = false;                      // reset the Quantified Self flag for next time\n  }\n  \n  if(millis() - fadeTime > 20){\n    fadeTime = millis();\n    ledFadeToBeat();                      // Makes the LED Fade Effect Happen\n    }\n    \n} // end of loop\n\n\n\n  ******************************************************************************************\n\n\n\n\n\n  ******************************************************************************************\n\n\n\n\n\n  ******************************************************************************************\n\n\n\n\n\n  ******************************************************************************************\n\n\n\n\n\n  ******************************************************************************************\n\n\n\n\n\n  ******************************************************************************************\n\n\n\n*/\n"
  },
  {
    "path": "README.md",
    "content": "# This code has been superseded\n# Please use our new [PulseSensor Playground Library](https://github.com/WorldFamousElectronics/PulseSensorPlayground)\n\n\n![logo](https://avatars0.githubusercontent.com/u/7002937?v=3&s=200)\n\n## Getting Advanced Code / <a href=\"http://www.pulsesensor.com\">PulseSensor</a>  & <a href=\"http://arduino.cc/\"> \"Arduino\"</a> \n* Blinks LED on Pin 13 to a User's Live Heartbeat.   \n* \"Fancy Fade Blink\" an LED on Pin 5, to a User's Live HeartBeat.\n* Calculates User's BPM, Beat-Per-Minute. \n* Calculates User's IBI, the Interval Between Beats.  \n* Serial.print's the Signal, BPM, and IBI.  Use this output for our <a href=\"https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer\">Processing Visualizer App</a> , our <a href=\"https://itunes.apple.com/us/app/pulse-sensor/id974284569?ls=1&mt=12\"> Pulse Sensor Mac App</a>, or your project!  \n* Tech Note:  Employ's Arduino's Interrupt, to keep \"time\", and calculate BPM and IBI.\n\n\n## Screen Shot\n![ScreenShot](pics/ScreenCapArduino.png) \n\n\n## Installing\n1. Click the `Clone or Download` button above and download the zip, or if you are a github user, clone this repo, or fork it! \n2. Take the **PulseSensor_Amped_Arduino-master.zip** file, and move it to your **Documents/Arduino** folder.\n3. **Unzip** PulseSensor_Amped_Arduino-master.zip in your **Documents/Arduino** folder. **This properly installs your files.**\n4. Double-click on **PulseSensorAmped_Arduino_1.5.0.ino** ![filesys](pics/filesys.png)\n\n\t**Or,** 0pen project in **Arduino via *File > Sketchbook > PulseSensor_Amped_Arduino-Master > PulseSensorAmped_Arduino_1.5.0.ino**\n ![sketchbook](pics/ArduinoSketch.png)\n\n\n## Pulse Sensor Hook-up\nArduino Pin   | PulseSensor Cable Color\n------------- | -------------\nRED           | 5V or 3V   \nBLACK         | GND (GROUND)\nPURPLE        | A0 (Analog Pin Zero)\n\n![cablehookup](pics/cablehookup.png)\n\n\n## Variables to Note\nVariable Name     | What it does\n------------------| -------------\nSignal            | **Int** that holds raw Analog Input data on **Pin 0**, the PulseSensor's **Purple Cable**. It's updated every 2mS\nBPM               | **Int** that holds the **heart-rate value**, derived every beat, from averaging **previous 10 IBI values** \nIBI               | **Int** that holds the **time interval between beats**\nPulse             | **Boolean** that is **true when a heartbeat is sensed**. It's **false** other times.  It **controls LED Pin 13**.\nQS                | **Boolean** that is **true whenever Pulse is found and BPM** is updated. User must reset. \n\n\n## Working with other Apps via Serial.print\nThis Arduino Sketch works with:\n\n* Our **Processing Sketch** <a href=\"https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer\"> \"Processing Visualizer\"</a>\n*  Our **Pulse Sensor Mac App** <a href=\"https://itunes.apple.com/us/app/pulse-sensor/id974284569?ls=1&mt=12\"> \"Pulse Sensor Mac App\"</a>\n*  The **Arduino Serial Plotter**\n\nFollow the links above to learn more about the Processing Visualizer and Mac App. This Read Me will cover how to view your pulse wave and other data with the Arduino Serial Plotter. There is a variable in the Pulse Sensor Amped Arduino Sketch that determines how the serial output is formatted. The variable is called `outputType`, and there are two options for setting this variable: `PROCESSING_VISUALIZER` and `SERIAL_PLOTTER`. By default, `outputType` is set to `SERIAL_PLOTTER`. \n\n![outputType](pics/outputType.png)\n\nIf you want to use the Serial Plotter, upload the Sketch to your Arduino microcontroller, and then select `Tools > Serial Plotter`.\n![Select Serial Plotter](pics/select-plotter.png)\n\nWhen you turn on the Plotter, make sure that the baud rate is set to 115200. Make this adjustment with the lower right corner menu selector. You will see three traces in the Arduino Serial Plotter. The **red** trace is your pulse wave data from the `Signal` variable. The **yellow** trace is your `IBI`, or the time between each beat. The **blue** trace is your `BPM` or your Beats Per Minute. \n\n![Serial Plotter Shot](pics/plotter.png)\n\nIf you only want to see the pulse wave `Signal` data, then you can edit the Arduino Sketch. In the `AllSerialHandling.ino` tab, simply comment out the lines shown below by inserting `//` in the beginning of the line.\n\n![comment data](pics/plot-pulse-only.png)\n\nNow, when you run the Serial Plotter, you will see a **blue** pulse waveform only!\n\n![plot pulse only](pics/plot-of-pulse-only.png)\n\n## Timer Interrupt Notes or \"Why did some of PWM Pins stop working ???\"\nThere is a tab in the Arduino code called `Timer_Interrupt_Notes`. This page describes how to set up the timed interrupt depending on which hardware you are using, and what other things you may want to do with your sketch. We are using a hardware timer on the micrcontroller to make sure that our Pulse Sensor samples are taken at a consistent rate. That makes our data extra scientific! Please read it carefully!\n\nPWM on pins 3 and 11 will not work when using this code, because we are using Timer 2!\n🤷‍♂️🤷‍♀️  \n\nInterrupt Setting | Disables PWM ON Arduino PINS \n----------------- | -------------\nTIMER2            |  3 AND 11  \n\n\n\n\n## Pulse Sensor Preparation [ Garbage In ~ Garbage Out ]\nIt's important to protect the Pulse Sensor from the oils and sweat that your fingertips and earlobes and other body parts make. That stuff can adversely affect the signal quality. Also, it's important to protect **you** from the electricity that makes the Pulse Sensor work! To this end, we have provided clear vinyl stickers that fit perfectly on the face of the Pulse Sensor. Peel one off, and press it firmly on the **front** side of your Pulse Sensor.\n![Stick](pics/stick.jpg)\n![Picture](pics/finger.jpg)\n![Picture](pics/earclip.jpg)\n\n## Troubleshooting\nHaving trouble making heads or tails of what is wrong?  \nCheck your raw signal with this project:\n<a href=\"https://github.com/WorldFamousElectronics/PulseSensorStarterProject\">WorldFamousElectronics/PulseSensorStarterProject</a> \n\n\n[![Alt text](https://github.com/WorldFamousElectronics/PulseSensorStarterProject/blob/master/video-play.png)](https://youtu.be/RbB8NSRa5X4)\n"
  }
]