#include <Arduino.h>

// Constants for Linear Regression (slope and intercept)
float slope = 0.5;  // Replace with the calculated slope
float intercept = 10.0;  // Replace with the calculated intercept

// Function to predict glucose values
float predictGlucose(float irValue) {
  // y = mx + c
  float predGlucoseValue = (slope * irValue) + intercept;
  return predGlucoseValue;
}

void setup() {
  Serial.begin(115200);
  delay(1000);  // Allow time for Serial monitor setup

  // Sample diyIrModuleValues for testing (simulating sensor input)
  float diyIrModuleValues[] = {5.2, 6.0, 7.1, 4.9, 8.5, 7.3, 6.8, 9.0, 5.5, 6.3}; // Test values
  int n = sizeof(diyIrModuleValues) / sizeof(diyIrModuleValues[0]);

  // Print predicted glucose values based on diyIrModuleValues
  Serial.println("Predicted Glucose Values:");
  for (int i = 0; i < n; i++) {
    float predictedGlucose = predictGlucose(diyIrModuleValues[i]);
    Serial.print("IR Value: ");
    Serial.print(diyIrModuleValues[i]);
    Serial.print(" -> Predicted Glucose: ");
    Serial.println(predictedGlucose);
  }
}

void loop() {
  // No continuous loop needed for demonstration
}