Hi,
You have this line
floatSwitch = digitalRead(6);
but no; not; EDITED.
pinMode(6, INPUT);
How have you got your float switch wired, between pin 6 and gnd or pin 6 and 5V?
If between pin 6 and 5V, have you got a 10K resistor between pin 6 and gnd to pull the pin LOW when the switch is open?
OR
If between pin 6 and gnd, have you got a 10K resistor between pin 6 and 5Vto pull the pin HIGH when the switch is open?
Can I suggest you give pin 6 a name such as floatPin , it will help with readability of your code.
Are you only using one float switch?
Please post a link to specs/data of the switch.
Can you please post a circuit diagram of your complete project so we can see your component layout.
Include your power supply, just a hand drawn schematic will be fine unless you have a CAD.
Tom...
![]()