Greetings, this my first post and I hope you could help me. I have found myself in a problem while doing a little project. My task is to do a home-made glucometer, but dont let it deceive you, it's just based on the voltage received hence to the amplifier. I´ve been working with a code and got all of the components I thought I would need. I´m quite new at this so I think that there might be a problem in the coding. The idea is that using the Voltage from the blood that goes trough the amp and to an analogic input of the Arduino, then using 'if' conditions turn Leds on or off depending of the value.
Right now the problem is that just one Led is turning on, and no matter what I do it does not change.
Here's the code:
int ledUH= 13;
int ledH= 12;
int ledN= 11;
int ledL= 10;
int ledUL= 9;
int INA= A0;
int ledState = LOW;
void setup() {
// put your setup code here, to run once:
pinMode (ledUH, OUTPUT);
pinMode (ledH, OUTPUT);
pinMode (ledN, OUTPUT);
pinMode (ledL, OUTPUT);
pinMode (ledUL, OUTPUT);
pinMode (INA, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int x = analogRead (INA);
int xDoubled = x*2;
Serial.print(INA);
Serial.println(" sensando");
Serial.print(xDoubled);
Serial.println(" Doble");
if(xDoubled <=170){ //Very low glucose
digitalWrite (ledUL, HIGH);
digitalWrite (ledUL, LOW);
delay(5000);
}
if(300>xDoubled <500){//Low glucose
digitalWrite (ledL, HIGH);
digitalWrite (ledL, LOW);
delay(5000);
}
if(510>xDoubled <690){//normal glucose
digitalWrite (ledN, HIGH);
digitalWrite (ledN, LOW);
delay(5000);
}
if(750>xDoubled <860){//Pre-diabetis
digitalWrite (ledH, HIGH);
digitalWrite (ledH, LOW);
delay(5000);
}
if(xDoubled >=900){ //Very high Glucose Level
digitalWrite (ledUH, HIGH);
digitalWrite (ledUH, LOW);
delay(5000);
}
}