-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOnePointCal.ino
More file actions
110 lines (91 loc) · 3.53 KB
/
OnePointCal.ino
File metadata and controls
110 lines (91 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// ************************************************
// One Point Calibration
// ************************************************
void OnePointCal() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("Calibration mode"));
lcd.setCursor(3, 1);
lcd.print(F("One-point"));
delay(5000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("Buffer pH:"));
lcd.setCursor(0, 1);
lcd.print(F(" . "));
Key = customKeypad.waitForKey();
midBuffer = (Key - '0') * 10;
lcd.setCursor(0, 1);
lcd.print(Key);
Serial.print(F("Tens place: "));
Serial.println(Key);
Key = customKeypad.waitForKey();
midBuffer = (Key - '0') + midBuffer;
lcd.setCursor(1, 1);
lcd.print(Key);
Serial.print(F("Ones place: "));
Serial.println(Key);
Key = customKeypad.waitForKey();
midBuffer = ((Key - '0') * 0.1) + midBuffer;
lcd.setCursor(3, 1);
lcd.print(Key);
Serial.print(F("Tenths place: "));
Serial.println(Key);
Key = customKeypad.waitForKey();
midBuffer = ((Key - '0') * 0.01) + midBuffer;
lcd.setCursor(4, 1);
lcd.print(Key);
Serial.print(F("Hundreths place: "));
Serial.println(Key);
Key = customKeypad.waitForKey();
midBuffer = ((Key - '0') * 0.001) + midBuffer;
lcd.setCursor(5, 1);
lcd.print(Key);
Serial.print(F("Thousanths place: "));
Serial.println(Key);
midcalstring = premidcalstring + String(midBuffer);
Serial.print(midcalstring);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("Press '#' to cal"));
while (Key != '#') {
/*
Serial1.print("R"); //Ask for pH reading
Serial1.print('\r'); //add a <CR> to the end of the string
if (Serial1.available() > 0) { //if we see that the Atlas Scientific product has sent a character
char inchar = (char)Serial1.read(); //get the char we just received
sensorstring += inchar; //add the char to the var called sensorstring
if (inchar == '\r') { //if the incoming character is a <CR>
sensor_string_complete = true; //set the flag
}
}
if (sensor_string_complete == true) { //if a string from the Atlas Scientific product has been received in its entirety
if (isdigit(sensorstring[0])) { //if the first character in the string is a digit
pH = sensorstring.toFloat(); //convert the string to a floating point number so it can be evaluated by the Arduino
}
sensorstring = ""; //clear the string
sensor_string_complete = false; //reset the flag used to tell if we have received a completed string from the Atlas Scientific product
}
*/
unsigned long sensor_currentMillis = millis();
if (sensor_currentMillis - sensor_previousMillis >= sensor_interval) {
sensor_previousMillis = sensor_currentMillis;
Get_pH();
Get_Temperature();
Set_Temp_Comp();
}
lcd.setCursor(0, 1);
lcd.print(F("pH="));
lcd.print(pH, 3);
Key = customKeypad.getKey();
}
Key = NO_KEY;
Serial1.print(midcalstring); //send that string to the Atlas Scientific product
Serial1.print('\r'); //add a <CR> to the end of the string
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("###Calibration##"));
lcd.setCursor(0, 1);
lcd.print(F("####Complete####"));
delay(3000);
}