Tired to figure this out myself for 3 days

// this code is made to control hydroponic garden water level

int ir_sensor = 5; // infread water leve sensor digital pin 5

int jug_led = 10; // low water red led

int safety_switch = 11; ; // float inside water container

int pbr = 12; // power brick relay (pump) digital pin 12

void setup() {
pinMode(ir_sensor, INPUT);

pinMode(pbr, OUTPUT);

pinMode(safety_switch, INPUT);

pinMode(jug_led, OUTPUT);
}

void loop() {
digitalWrite(ir_sensor, LOW); // if the sensor is wet it will not turn on
if (ir_sensor < HIGH) { // infread sensor is wet
digitalWrite(pbr, HIGH); //turns on power brick relay
} else {
digitalWrite(ir_sensor, LOW); // shuts relay off now filled to the right water level
}

digitalWrite(safety_switch, HIGH); // water tank float is in the has water position
if (safety_switch < LOW) { // water tank float is no longer full
digitalWrite(pbr, LOW); // stops the power brink relay to pervent pump from running, maybe fire
} else {
digitalWrite(safety_switch, HIGH); // water tank float is in the has water position
}
if (safety_switch< LOW){ // float has detremand low water level
digitalWrite(jug_led,HIGH); // turns on anoying red led to alert idiots its empty
}else{
digitalWrite(jug_led,LOW); // led is no on because idiots filled me
}
// delay will be added after test
}

I checked the circuit. I keep changing the code here and there. Counter productive because, 0ne I dont know what I did wrong, and two because i am not learning anything from it. Is there anyone that sees what I have done wrong. And can anyone explain why nothing is working. This the code I originally wrote.

I have found a few things I did wrong and senses fix but I fear that I a missing lot

I have seen my error with setting the beginning of the loop and not starting with digitalRead(global valve)

Definitely the first code I have written. Of this complexity. Even knowing this is extremely easy,for those who know.

Why are you writing to input pins? Are the inputs pulled up or down externally or are they floating?

if (safety_switch < LOW)

LOW is 0 so what would be less than 0?

if (safety_switch < LOW)

safety_switch is a pin number (11) and will never be less than LOW (LOW is equal to zero).

digitalWrite(ir_sensor, LOW);                  // shuts relay off now filled to the right water level

ir_sensor is an input pin, not an output, so this statement won't affect a relay.

You should start with the simple examples that come with the Arduino program development software (read a switch, a voltage, blink an LED without using delay(), etc. That way you learn the language and special features of the Arduino, and avoid a great deal of frustration.

Ir sensor is power 390 resistor. 4 wire pin out the photo senor on the side is pulled down with a 4.7 resistor.

In your if statements, do you mean to write == and not <?

Metallor:
In your if statements, do you mean to write == and not <?

That's one of the things I looked at and changed it a while ago. I would post my re edited but I think it would make anyone just shake their head

centerpoo:
That's one of the things I looked at and changed it a while ago. I would post my re edited but I think it would make anyone just shake their head

People can't help you unless you post the current code that isn't working

When you do repost your (redone) code, please type "[code]" before your code, then "[/code]" after it. People will shake their heads less if you do that.

ChrisTenone:
When you do repost your (redone) code, please type "[code]" before your code, then "[/code]" after it. People will shake their heads less if you do that.

And also make sure you post as a reply in this thread, and not edit your original post with the new code.

Metallor:
And also make sure you post as a reply in this thread, and not edit your original post with the new code.

ChrisTenone:
When you do repost your (redone) code, please type "[code]" before your code, then "[/code]" after it. People will shake their heads less if you do that.

Good to know. Learning a new language is some what difficult.I fear the code has been terribly screwed
up because off guessing. So many ways to do/write things that are capable of doing the same task. I will go and repost it after I edit it.
What I can tell you is i got a as far as the relay coming on/ pump on but never shut off or turned on my led the infrared photo senor in or out of water never changed anything. I have mechanical flot switch that will sit inside the reservoir. Also moved physically to check.