need some guidance with my code [solved]

hi all, I'm very new to coding and struggling with the code I'm trying to write. I'm working on a larger project but since its all new to me I've broken it down into individual functions. This one is to measure a water tank in quarter increments which once i get working I will display on a lcd . when I run the code nothing happens, I'm testing it by connect a0/14 to 5v so it reads HIGH. not sure what im missing or if what im doing is correct. i know that it can be done through analog but thats more confusing. If I could get some hints or tips that would be amazing.

const int qtr = 14;
const int half = 15;
const int Threeqtr = 16;
const int full = 17;


void setup() {
  // put your setup code here, to run once:
  pinMode (qtr, INPUT);
  pinMode (half, INPUT);
  pinMode (Threeqtr, INPUT);
  pinMode (full, INPUT);
  Serial.begin(9600);
  

}

void loop() {
{
  digitalRead(qtr);
  digitalRead(half);
  digitalRead(Threeqtr);
  digitalRead(full);
  
  if ((qtr == HIGH) && ( half == LOW))
    {  Serial.print("25");
    delay(750);}

else
  if ((half == HIGH) && ( Threeqtr == LOW))
     { Serial.print("50");
      delay(750);}
     
  else 
    if ((Threeqtr == HIGH) && ( full == LOW)) 
        {Serial.print("75");
        delay(750);}
  else 
    if (full == HIGH)
      {Serial.print("100");
      delay(750);}
   }
  
}

sketch_jun19b.ino (764 Bytes)

Hi you are not saving the State of qrt, half, threeqtr and full.

//first assign a pin to the sensor
// in your case
const int qtr = 14;

void setup(){
// now assign the pin to be a input or output
pinMode(qtr, INPUT);
}

void loop(){
//now get a value from the pin and save it to a variable.
int qtrState = digitalRead(qtr);

//now use the state to print something on the serial monitor
if(qrtState == HIGH){
   Serial.println("25");
} else if(otherstae == high){
//print something else

Learn to read and follow instructions Try starting with the ones for this forum.

Mark

Your if statements are checking to see if the pin numbers are HIGH or LOW. Since they're all not 0 then they're all HIGH. Perhaps try checking something else, like the results of the digitalReads that you read then throw away.

Steve

Thanks heaps spirit that's all it needed. I really appreciate it