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)