I'm having some trouble with my Arduino code. I'm trying to make a DIY glucometer using my Elegoo Uno R3 (Arduino/Genuine Uno). Currently, my code is supposed to take input from analog pin A0, convert it to a voltage value, and, using that voltage, I give an output on my LCD board in mmol/L (blood sugar units).
Here is my code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);
void setup() {
Serial.begin(9600);
lcd.begin(16,2); // set up the LCD's number of columns and rows:
}
void loop() {
int sensorValue = analogRead(A0); // read the input on analog pin 0:
int voltage = sensorValue * (5 / 1023); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
if (voltage <= 170) { //if voltage < 2mV, your blood glucose is v/ low
lcd.print(voltage + " mmol/L");
exit(0);
}
else if (300 < voltage < 500) { //between 2.8 mV and 6.5 mV your BG is low
lcd.print(voltage + " mmol/L");
exit(0);
}
else if (510 < voltage < 690) { //between 7 mV and 11 mV your BG is normal
lcd.print(voltage + " mmol/L");
exit(0);
}
else if (750 < voltage < 860) { //between 2.8 mV and 6.5 mV your BG is high
lcd.print(voltage + " mmol/L");
exit(0);
}
else if (voltage < 900) { //v/ high BG
lcd.print(voltage + " mmol/L");
exit(0);
}
}
However, whenever I upload this program, I get "32(≡≡≡ mmol/L". The triple bars I just showed are actually quadruple bars on the LCD. In what I mentioned above, the voltage is 0, but when I tried using the same program with a different lcd.print value, like "hello", the 32(≡≡≡ still showed up before it. I'm not sure what these characters mean or how I can get rid of them. Let me know if you have any idea or are experiencing a similar issue.