A float switch is an essential device used to detect and control the level of liquid within a tank or container. It operates on a simple mechanism: a buoyant float is attached to a switch, which activates as the liquid level rises or falls. This makes float switches ideal for applications such as automatic water level control in tanks, sump pump activation, and overflow prevention.
Pin Number | Description |
---|---|
1 | Common (COM) |
2 | Normally Closed (NC) Contact |
3 | Normally Open (NO) Contact |
Q: Can I use a float switch with any liquid? A: Float switches are designed for use with a variety of liquids, but always check the material compatibility with the specific liquid in your application.
Q: How do I adjust the switch activation point? A: Adjust the mounting height of the float switch to change the activation point.
Q: Is it possible to use a float switch with an Arduino? A: Yes, a float switch can be connected to an Arduino's digital input pin for liquid level sensing.
// Define the float switch pin
const int floatSwitchPin = 2;
void setup() {
pinMode(floatSwitchPin, INPUT_PULLUP); // Set the float switch pin as an input
Serial.begin(9600); // Start serial communication
}
void loop() {
// Read the state of the float switch
int floatSwitchState = digitalRead(floatSwitchPin);
// Check if the float switch is triggered (assuming NO configuration)
if (floatSwitchState == LOW) {
// The liquid level has reached the float switch
Serial.println("Liquid level high");
} else {
// The liquid level is below the float switch
Serial.println("Liquid level low");
}
delay(1000); // Wait for 1 second before reading again
}
Note: The above code assumes the float switch is wired in a Normally Open (NO) configuration. If your switch is Normally Closed (NC), the logic in the if
statement will be reversed.