I have a problem. I don’t know how to combine this two codes & the diagram. My project is about automatic water storage door that using water sensor & rain sensor. The rain sensor will function when rain while the water sensor will control the open/close door. The door will open when it rain but it will remain close when the volume in the water storage is full.the volume of water in tank was controlled by flood sensor(water sensor). Here is the code for two sensor.
rain sensor const int senmin = 0; const int senmax = 1024; int led = 13; int sensory = A0; int i; void setup() { Serial.begin (9600); pinMode(led, OUTPUT); }
void loop() { int sensor = analogRead(sensory); int range = map(sensor, senmin, senmax, 0, 3);
switch (range) { case 0: Serial.println("raining"); digitalWrite(led, HIGH);
break;
case 1:
Serial.println("not raining");
digitalWrite(led,LOW);
} delay(500);
}
water sensor
const int waterSens = A0; //define water sensor const int led = 9;//define led to pin 9 int waterVal; //define the water sensor value
void setup() { pinMode(led, OUTPUT); //set led as an output pinMode(waterSens, INPUT);//set water sensor as an input Serial.begin(9600); //start the serial port at 9600 bauds
}
void loop() { waterVal = analogRead(waterSens); //read the water sensor
Serial.println(waterVal); //print the value of the water sensor to the serial monitor
if (waterVal <= 0){ digitalWrite(led, HIGH);//if the water sensor senses water turn the led on } else{ digitalWrite(led, LOW);//if it doesn't sense anything turn the led off } }