aboutsummaryrefslogtreecommitdiff
path: root/Detector-Building.ino
diff options
context:
space:
mode:
Diffstat (limited to 'Detector-Building.ino')
-rw-r--r--Detector-Building.ino10
1 files changed, 5 insertions, 5 deletions
diff --git a/Detector-Building.ino b/Detector-Building.ino
index 498a114..b2c49d3 100644
--- a/Detector-Building.ino
+++ b/Detector-Building.ino
@@ -28,10 +28,9 @@ int d2a(double d) { return d * analog_max / V_in; }
// Voltage to resistance conversion
double v2r(double V_out) { return R_k * (V_in / V_out - 1); }
-double vol[100];
-int con[100];
+double vol[100], con[100];
-const int order = 2;
+const int order = 1;
double coeff[order + 1];
void setup() {
@@ -53,13 +52,14 @@ void setup() {
++n;
}
- fitCurve(order, n, vol, con, coeff);
+ fitCurve(order, n, vol, con, order + 1, coeff);
+ for (int i = 0; i <= order; ++i) Serial.println(coeff[i]);
}
void loop() {
double v = a2d(analogRead(THERM));
double c = 0;
- for (int i = order; i >= 0; --i) c = v*c + coeff[i];
+ for (int i = 0; i <= order; --i) c = v*c + coeff[i];
Serial.print("Voltage: ");
Serial.println(v);