WATER LEVEL SENSOR CODE

                        (WATER LEVEL SENSOR CODE)



                  ( PROGRAMMING CODE )



const int analogInPin = A0;

int sensorValue = 0;

void setup() {

  pinMode(2,OUTPUT);

  pinMode(3,OUTPUT);

  pinMode(4,OUTPUT);

  pinMode(5,OUTPUT);

  Serial.begin(9600);

}

void loop() {

  sensorValue = analogRead(analogInPin);

  Serial.print("sensor = ");

  Serial.print(sensorValue);

  Serial.print("\n");

  delay(2);

  if((sensorValue>=100)&&(sensorValue<=600)){

    digitalWrite(2,HIGH);

    delay(100);

    }

  else if((sensorValue>=601)&&(sensorValue<=610)){

   digitalWrite(3,HIGH);

   delay(100);

    }  

  else if((sensorValue>=626)&&(sensorValue<=750)){

    digitalWrite(4,HIGH);

    digitalWrite(5,HIGH);

    }

  else{

    digitalWrite(2,LOW);

    digitalWrite(3,LOW);

    digitalWrite(4,LOW);

    digitalWrite(5,LOW);

    delay(100);

    }

}



Post a Comment

Previous Post Next Post

Contact Form