Adafruit Circuit Express Error With SAMD Interrupts

Hello,
I was working with some code on my home computer and without plugging in the actual board the code works fine and does not produce any errors, however, when I plug in the board to upload code the Arduino IDE asks to download additional libraries to deal with the board, after this happens I get an error from one of the libraries I am using (PulseSensorPlayground.h) saying that it cannot find <#include "SAMDTimerInterrupt.h"/>
I cannot find any information online about this specific error, besides trying to install the SAMD Timer Interrupt (did not work). For some additional info, although I do not think the issue is with my code, I will paste it below. I am trying to make a heartbeat monitor that also reports when it detects a spike or drop in HR, then alerts the user and displays a message.


#define PULSE_SENSOR_PIN A3


#include <PulseSensorPlayground.h>     // Includes the PulseSensorPlayground Library.   
#include <Adafruit_CircuitPlayground.h>
//#include <SPI.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2); // Makes the LCD 
int pulseValue; 
int WarningThreshold = 30;
int Threshold = 550; 
unsigned long lastBeatTime = 0; 
int BPM; 
int BPMChange = 0;
int previousBPM = -1;
int BPamp; 
unsigned long startTime = 0;
const int PulseWire = 3;       // PulseSensor RED WIRE connected to ANALOG PIN 3
const int LED13 = 13;          // The on-board Arduino LED, close to PIN 13.
PulseSensorPlayground pulseSensor;  // Creates an instance of the PulseSensorPlayground object called "pulseSensor"
int xdata; int ydata; int zdata;
 

void setup() {   
  Serial.begin(9600);          // For Serial Monitor
  CircuitPlayground.begin();
  lcd.init(); 
  lcd.backlight();
  startTime = millis();
  pulseSensor.analogInput(PulseWire);   
  pulseSensor.setThreshold(Threshold);   
  // Double-check the "pulseSensor" object was created and "began" seeing a signal. 
   if (pulseSensor.begin()) {
    Serial.println("Start Data");
    lcd.setCursor(0,0);
    lcd.print("Welcome To"); 
    lcd.setCursor(0,1);
    lcd.print("POTS Portable");
    }
    else {
      lcd.setCursor(0,0);
      lcd.print("Error"); //This prints one time at Arduino power-up,  or on Arduino reset.  
    
    }



}

void Alert() {
  for (int i = 0; i < 3; i++) { // Beep 3 times
    CircuitPlayground.playTone(440, 500); // 440 Hz for 500 ms
    delay(200); // Small pause between beeps
  }
}

void Flash() {
  for (int i = 0; i < 3; i++) { // Flash 3 times
    CircuitPlayground.setPixelColor(0, 255, 0, 0); // Set all LEDs to red
    delay(200);
    CircuitPlayground.clearPixels(); // Turn off LEDs
    delay(200);
  }
}

void GetAccelData() {
  xdata = CircuitPlayground.motionX();
  ydata = CircuitPlayground.motionY();
  zdata = CircuitPlayground.motionZ();
}


//continuous window 
//HEART RATE DISPLAY and HR CHANGE
void loop() {
 int BPM = pulseSensor.getBeatsPerMinute();   // Calls function on our pulseSensor object that returns BPM as an "int".
 if (pulseSensor.sawStartOfBeat()) {             // Constantly test to see if "a beat happened". 
  Serial.print("BPM:");                           // Print phrase "BPM: " 
  Serial.println(BPM);    
  lcd.setCursor(0,0);
  lcd.print("BPM:"); 
  lcd.setCursor(8,0);
  lcd.print("       "); // Clear previous BPM        
  lcd.setCursor(8,0);
  lcd.print(BPM);    
  pulseSensor.blinkOnPulse(LED13);   // added now not sure if works 

  if(previousBPM >= 0 ){
    float BPMChange = abs(previousBPM-BPM);
    Serial.print("Difference: ");
    Serial.print(BPMChange);
  }
  if (BPMChange > WarningThreshold) {    // This whole thing just basically says that if the change is greater than the threshold, display a warning on the LCD, flash and make a sound, then store all that data in the Serial file 
    Serial.println("A POTS Event may be Occuring");
    lcd.setCursor(0,0);
    lcd.print("      POTS      ");
    lcd.setCursor(0,1);
    lcd.print(" Event Occuring");
    // Panic 
    Alert();
    Flash();
    // Acceleration Data recording
    GetAccelData();    // Gets the acceleration data
    Serial.print("X : ");    // Prints acceleration data to serial file
    Serial.print(xdata);
    Serial.print("Y : ");
    Serial.print(ydata);
    Serial.print("Z : ");
    Serial.print(zdata);
    // Blood pressure reading (needs to be calibrated, right now this just returns the amplitude of the wave (peak - trough))
    BPamp = pulseSensor.getPulseAmplitude();
    Serial.print("BP Amp : ");
    Serial.print(BPamp);

  }

  previousBPM = BPM;     // make the current BPM -> Old, then start over again 
  lastBeatTime = millis();  

  //Serial.print("Light Sensor Value: "); 
  //Serial.println(lightValue); 
  
  delay(20);                                
  }
}

What board is selected?

1 Like

I thinki you either didn't notice the compiler error or you have compiler warnings set to NONE (Unwise) because although your code does not use SAMD_TimerInterrupt, another of your includes (CircuitPlayground) does so you need to install the library. Once I did that it compiled ok.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.