Mini Reed

The Mini Reed Sensor module is a compact and versatile component used to detect the presence or absence of a magnetic field. It consists of a reed switch enclosed in a small casing. When exposed to a magnetic field, the reed switch’s contacts close, completing an electrical circuit. In this step-by-step guide, we’ll show you how to set up the Mini Reed Sensor module with an Arduino and create projects that respond to the presence of magnets.

Materials Needed:

  1. Arduino board (e.g., Arduino Uno, Arduino Nano)
  2. Mini Reed Sensor module
  3. Magnet (e.g., a small neodymium magnet)
  4. Resistor (220 ohms or 10k ohms, depending on the module)
  5. Breadboard and jumper wires
  6. USB cable for Arduino
  7. Computer with the Arduino IDE installed (https://www.arduino.cc/en/software)

Step 1: Wiring

Connect the Mini Reed Sensor module to the Arduino board as follows:

  • Connect the module’s VCC (Voltage) pin to the 5V pin on the Arduino.
  • Connect the module’s GND (Ground) pin to the GND pin on the Arduino.
  • Connect the module’s OUT (Output) pin to a digital pin on the Arduino (e.g., D2).
  • Place a resistor (220 ohms or 10k ohms) between the OUT pin on the module and the GND pin on the Arduino (choose the resistor value based on the specifications of your module).

Step 2: Arduino Code

Open the Arduino IDE and create a new sketch. Then, enter the following code:

const int reedSensorPin = 2; // Digital pin connected to the Mini Reed Sensor module

void setup() {
pinMode(reedSensorPin, INPUT_PULLUP); // Set the Reed Sensor pin as INPUT_PULLUP
Serial.begin(9600); // Initialize serial communication for debugging (optional)
}

void loop() {
int reedState = digitalRead(reedSensorPin); // Read the state of the Mini Reed Sensor

if (reedState == LOW) {
Serial.println(“Magnetic field detected!”); // Display a message when a magnet is detected
// Your custom actions or functions can be added here.
} else {
Serial.println(“No magnetic field.”); // Display a message when no magnet is detected
}

delay(100); // Add a small delay to avoid rapid repeated detections
}

Step 3: Uploading the code

Connect your Arduino board to the computer using the USB cable and select the appropriate board and port from the Arduino IDE. Then, click the “Upload” button to upload the code to the Arduino.

Step 4: Observing the Magnetic Detection

Once the code is uploaded successfully, open the Serial Monitor from the Arduino IDE (Ctrl + Shift + M). The Serial Monitor will display “Magnetic field detected!” whenever a magnet is brought close to the Mini Reed Sensor module. It will show “No magnetic field.” when no magnet is nearby.

Step 5: Experiment and Interact

Now that the Mini Reed Sensor module is set up and responding to magnets, you can experiment with different magnet placements and strengths. Adjust the code to trigger various actions or events in response to the presence or absence of a magnetic field. For example, you can use the Mini Reed Sensor module to detect the opening or closing of a door or window, build a magnetic security system, or create interactive installations.

Congratulations! You’ve successfully set up and used the Mini Reed Sensor module with Arduino. This compact sensor allows you to detect the presence of magnets and opens up a wide range of possibilities for interactive projects and security applications. Have fun experimenting and incorporating the Mini Reed Sensor module into your Arduino projects to add a touch of magnetic magic!

0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*

or

Log in with your credentials

Forgot your details?