[Code] edited

Original code. Senor working but I cant get the float switch to shut the relay off when closed

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

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

const int jug_led = 10; // low water red led

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

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

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

pinMode(safety_switch, INPUT);

pinMode(pbr, OUTPUT);

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
}

Edited

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

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

const int jug_led = 10; // low water red led

const int safety_switch = 12; ; // float inside water container

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

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

pinMode(safety_switch, INPUT);

pinMode(pbr, OUTPUT);

digitalWrite(pbr,LOW);

digitalWrite(pbr, LOW);

pinMode(jug_led, OUTPUT);

digitalWrite(jug_led, LOW);
}

void loop() {
// if the sensor is wet it will not turn on
int led = digitalRead(ir_sensor);

if (led) { // infread sensor is wet

digitalWrite(pbr, LOW); //turns on power brick relay

} else {

digitalWrite(pbr, HIGH); // shuts relay off now filled to the right water level
}

digitalRead(safety_switch); // water tank float is in the has water position
if (safety_switch, HIGH){ //ater tank float is no longer full
digitalWrite(pbr, LOW); // stops the power brink relay to pervent pump from running, maybe fire
} else {
digitalWrite(pbr, LOW); // water tank float is in the has water position
}
delay(50);

}

  if (safety_switch, HIGH)

That is not how you test whether a pin is in a HIGH state

HINT : you need to read the state of the digital pin

I just started over and add things instead of having fix the whole thing at once

UKHeliBob:

  if (safety_switch, HIGH)

That is not how you test whether a pin is in a HIGH state

HINT : you need to read the state of the digital pin

I think I am getting confused on how I should be writing the globals. Should be using # define?

centerpoo:
I just started over and add things instead of having fix the whole thing at once
I think I am getting confused on how I should be writing the globals. Should be using # define?

The problem has nothing to do with declaring variables or using #defines

Do a Google search for if statements in C and look at the examples

and use "digitalRead()" to get the value of the pin.

Another problem Is I just checked the board and used a different one with headers lose. Tryed the button blink example wasn't working.

Plus the switch has internal resistance 400k just realized it's analog.

by now "I" am getting confused..

Deva_Rishi:
by now "I" am getting confused..

Basically I didn't know I was talking about but the board I was using was the original uno. The plastic header are 4 different headers and because it's not az strong as the new ones, that are just 2 header rails its was weaker and broke. It was a gift, it the board I use first because if I blow it up, i wouldn't care.

And lastly I didn't really comprehend the pull up resistor logic. Because it's a switch I needed a 10 k resistor, I have it reading in digital now. It's working now. I just need to add the led.