Control of water level with arduino HELP!

Hi, I'm working on an assignment that needs to meet the below requirements. This is my first time using C++ and
wanted to know if the code I've written is going about this in the right way.

Scenario
a control system is used to maintain the water level in a sump between the levels high and low. Two transducers
(HIGH and LOW) are used to monitor the level. The water is pumped out by two pumps, P1 and P2.
The water level in the sump is to be controlled as follows:

 If the level reaches high one pump will start to pump out.

 If the level does not reach low within about 30 seconds, the second pump will come into action. If the level does reach low before 30 second pumping should stop.

 If the level does not reach low within about 30 seconds of the second pump starting, an alarm is given. The alarm is sounded until the level reaches low.

If the level does reach low before 30 seconds the pumping should stop.
 The pumps will stop when low is detected.

 To give even loading of the pumps they are to be used alternately, e.g. if on one pump cycle P1 starts first and P2 is the ‘back up’ then on the next cycle P2 will start first and P1 is the ‘back up’

I have no experience with code and i am struggling to work out where i am going wrong.
Any help is much appreciated

Thanks

int Pump1 = 8; 
int Pump2 = 9;
int Alarm = 4;
int sensorPin = 1;

int LowWaterLevel = 1023*0.1;
int HighWaterLevel = 1023*0.9;


void setup()
{
  pinMode (Pump1,OUTPUT);
  pinMode (Pump2,OUTPUT);
  pinMode (Alarm,OUTPUT);
}

void loop()
{
  if(analogRead(sensorPin)<=HighWaterLevel)
  digitalWrite(Pump1, LOW);
  
}


 
if(analogRead(sensorPin)>=HighWaterLevel)
{digitalWrite(Pump1,HIGH);
delay(30000);

}

if(analogRead(sensorPin)<=LowWaterLevel)
{digitalWrite(Pump1,LOW);

}

else{digitalWrite(Pump2,HIGH);
delay(30000);
}

if(analogRead(sensorPin)<=LowWaterLevel)
{digtalWrite(Pump1 && Pump2,LOW);

}

else{digitalWrite(Pump1&&Pump2, LOW);
digitalWrite(Alarm,HIGH);
}

if(analogRead(sensorPin)<=LowWaterLevel)
{DigitalWrite(Alarm, LOW);

}

File 1.pdf (60.3 KB)

Please put your code in-line with your post. Like this:

Put your code here using the left-most icon in your replay

Paul

Thanks Paul

The water level in the sump is to be controlled as follows:

What are you using for the water level sensors?

Link to the sensor?

Also show us your schematic.

Thank you for posing your code in-line.

But, I see this:

int LowWaterLevel = 10230.1;
int HighWaterLevel = 1023
0.9;

Doesn't accomplish much, since an integer, by definition is a whole number. No decimal point, etc. So both will probably end up as zero.

Paul

@dublin2019

You do know you cannot have code outside of a function.

To time things, do you know how to use the BWD technique (blink without delay)?

There is an example in the IDE.

Also see Robin2's discussion:
http://forum.arduino.cc/index.php?topic=223286.0

What is this assignment for?