aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-01-15 21:16:14 -0600
committerAnthony Wang2022-01-15 21:16:14 -0600
commitf79df9410b6e356c3e371cd127ed6bfe64d95f18 (patch)
tree438b0f5c371051a7cb3beef10351593309e47947
parentfdc09cd2184a56a9eb5e9340823d30ab0d28f3d8 (diff)
Move new code to main.ino
-rw-r--r--main.ino57
1 files changed, 57 insertions, 0 deletions
diff --git a/main.ino b/main.ino
new file mode 100644
index 0000000..b59d7b2
--- /dev/null
+++ b/main.ino
@@ -0,0 +1,57 @@
+/*
+ ____ __________________________________ ____
+ / __ \/ ____/_ __/ ____/ ____/_ __/ __ \/ __ \
+ / / / / __/ / / / __/ / / / / / / / / /_/ /
+ / /_/ / /___ / / / /___/ /___ / / / /_/ / _, _/
+/___________/ __________/\____/ _____\__________|
+ / __ )/ / / / _/ / / __ \/ _/ | / / ____/
+ / __ / / / // // / / / / // // |/ / / __
+ / /_/ / /_/ // // /___/ /_/ // // /| / /_/ /
+/_____/\____/___/_____/_____/___/_/ |_/\____/
+
+Ladue Horton Watkins High School Science Olympiad
+
+Licensed under the Parity Public License
+*/
+
+
+using ld = long double;
+
+
+const int LED_R = 8, LED_G = 10, LED_B = 12, THERM = 0; // Device component pins
+const ld R_k = 10000, V_in = 5, analog_max = 1023; // Device constants
+
+// Analog to digital conversion
+ld a2d(int a) { return V_in * a / analog_max; }
+int d2a(ld d) { return d * analog_max / V_in; }
+
+// Voltage to resistance conversion
+ld v2r(ld V_out) { return R_k * (V_in / V_out - 1); }
+
+ld vol[100];
+int con[100];
+
+void setup() {
+ Serial.begin(9600);
+ Serial.println("Starting calibration")
+ Serial.println("Place sensor in water and enter the concentration into the console")
+ Serial.println("When you are finished, type c to continue")
+
+ int n = 0;
+ while (1) {
+ String s = Serial.readString();
+ if (s == "c") break;
+ vol[n] = a2d(analogRead(THERM));
+ con[n] = toInt(s);
+ Serial.println(n);
+ Serial.println(vol[n]);
+ Serial.println(con[n]);
+ ++n;
+ }
+
+
+}
+
+void loop() {
+
+}