Pin Name | Description |
---|---|
VCC | Power supply pin. Connect to 3.3V or 5V DC. |
GND | Ground pin. Connect to the ground of the power supply. |
OUT | Digital output pin. Outputs HIGH (1) when the reed switch is open, and LOW (0) when closed. |
Power the Module:
VCC
pin to a 3.3V or 5V DC power source. GND
pin to the ground of the power source.Connect the Output:
OUT
pin to a digital input pin of a microcontroller (e.g., Arduino UNO). Place a Magnet:
// Reed Switch Module Example Code for Arduino UNO
// This code reads the state of the reed switch and prints it to the Serial Monitor.
const int reedSwitchPin = 2; // Connect the OUT pin of the module to digital pin 2
int reedState = 0; // Variable to store the state of the reed switch
void setup() {
pinMode(reedSwitchPin, INPUT); // Set the reed switch pin as input
Serial.begin(9600); // Initialize serial communication at 9600 baud
}
void loop() {
reedState = digitalRead(reedSwitchPin); // Read the state of the reed switch
if (reedState == LOW) {
// Reed switch is closed (magnet nearby)
Serial.println("Magnet Detected!");
} else {
// Reed switch is open (magnet far away)
Serial.println("No Magnet Detected.");
}
delay(500); // Wait for 500ms before reading again
}
The module does not detect the magnet:
False triggers or unstable output:
Output signal is always HIGH or LOW:
OUT
pin is properly connected to the microcontroller.Q: Can I use the reed switch module with a 12V power supply?
A: No, the module is designed to operate at 3.3V to 5V DC. Using a higher voltage may damage the module.
Q: How far can the magnet be placed from the reed switch?
A: The distance depends on the strength of the magnet and the sensitivity of the reed switch. Typically, it ranges from a few millimeters to a few centimeters.
Q: Can the reed switch module detect non-magnetic objects?
A: No, the reed switch operates based on magnetic fields and cannot detect non-magnetic objects.
Q: Is the reed switch module polarity-sensitive?
A: No, the reed switch itself is not polarity-sensitive, but ensure proper connections for the module's circuitry.