water level sensor

hy guys i was wandering can you connect a float switch to 2 digital pins and tell one to send and one to recive and then make an if statmen if this one recives(HIGH) its connected or when it doesnt recive (LOW)?

or do i have to do something else like connect it to the ground power and then a digital pin?

5V and a digital pin (INPUT)

loop(){

if(digitalread(digitalpin)){ digitalwrite(otherpin,HIGH) } else digitalWrite(otherpin,LOW); } will this work?

A logical 0 or 1 isn't sending or receiving any significant serial info. like you may be speculating its just a logical 1 when the pin is HIGH(5v or 3.3v) or LOW with logical 0 or 0volts , why you need to read a single pin and two pin points? A single digital pin configured as digitalRead works for both the logical 0 and logical 1 scenarios , it gives you a HIGH when you connect voltage to it and low when it isn't connected with any voltage and write a IF condition to form a controlling procedure, simple!

soo i can simply connect a 5V -switch -digital pin ?

and put an if statment if its HIGH or LOW?

soo i can simply connect a 5V -switch -digital pin ?

and put an if statment if its HIGH or LOW?

Yes Just read a digital pin configured as pinMode(x,INPUT);(Input) and look for the HIGH or LOW in the if condition ,also make sure that the voltage you use to power the float switch is not more than you used to power the Arduino.

I would either use the internal pull-up or wire in an external pull-up in the form of a 10k resistor, then have the float switch wired up to ground that digital input.

You should not just connect a switch to 5V and then to a digital input. Without a pull-down resistor, the high impedance input will float and give you unreliable readings.