---
title: "Controlling Light Bulb in Your Room Using MC-38 Wired Magnetic Door Sensor"
url: "https://maker.wiznet.io/nagamma06/projects/controlling-light-bulb-in-your-room-using-mc-38-wired-magnetic-door-sensor/"
markdown_url: "https://maker.wiznet.io/nagamma06/projects/controlling-light-bulb-in-your-room-using-mc-38-wired-magnetic-door-sensor/md"
type: "UCC: User Created Content"
author: "Rucksikaa_R"
author_url: "https://www.instructables.com/Controlling-Light-Bulb-in-Your-Room-Using-MC-38-Wi/"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "Rucksikaa_R"
original_url: "https://www.instructables.com/Controlling-Light-Bulb-in-Your-Room-Using-MC-38-Wi/"
published: "2022-11-02"
language: "en"
hardware: ["Arduino UNO", "WIZnet W5100 ethernet shield"]
likes: 3
views: 850
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Controlling Light Bulb in Your Room Using MC-38 Wired Magnetic Door Sensor

> Controlling Light Bulb in Your Room Using MC-38 Wired Magnetic Door Sensor

Original author: Rucksikaa_R (source: https://www.instructables.com/Controlling-Light-Bulb-in-Your-Room-Using-MC-38-Wi/)

## Components

- **Arduino UNO** x 1 ([docs](https://www.farnell.com/datasheets/1682209.pdf))
- **WIZnet W5100 ethernet shield** x 1 ([docs](https://www.wiznet.hk/en/open-source-hardware/102-w5100s-ethernetshield.html?search_query=W5100+ethernet+shield&results=84))
- Software: **Arduino IDE** ([docs](https://www.arduino.cc/en/software))
- Software: **Blynk** ([docs](https://blynk.io/))

## Article

**Other Components are:**

1. MC-38 Wired Magnetic Door sensor

2. Relay module - 5V (1 channel)

3. Light Emitting Diodes (LEDs) - 03 (Green, Red and Any other colour you like)

4. Resistors - 03 (one 10kΩ and two 220Ω)

5. Solderless Breadboard

6. Jumper cables (3 male-to-female and 5 male-to-male)

7. Screwdriver

8. Power Bank - 10000mAh

9. USB Cable

10. Ethernet Cable

**Hardware setup:**

![](https://content.instructables.com/ORIG/FN6/LDTO/JYG85PJN/FN6LDTOJYG85PJN.jpg?auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=c127583519c50f4753b95b27e3ddcd6d) ![](https://content.instructables.com/ORIG/F6V/J4MA/JYG85U7B/F6VJ4MAJYG85U7B.jpg?auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=c6848ade012ffb50bf67c3318d14b510)

![](https://content.instructables.com/ORIG/FS4/T9ZE/JYG85WFP/FS4T9ZEJYG85WFP.jpg?auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=ee221bdb7deed8030f6973cc0a660134) ![](https://content.instructables.com/ORIG/FS7/MTNC/JYG85YOI/FS7MTNCJYG85YOI.jpg?auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=210ec153a36ac3040b5e6f65ba46677a)

![](https://content.instructables.com/ORIG/F59/MBLV/JYG85YY5/F59MBLVJYG85YY5.jpg?auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=e4eab02badcbc9edd996c0124cbfd9b9)

**ConnectionsRelay Module:**

To Arduino

- **S ----> D8 (Digital I/O pin)**

- **+ ----> 5V**

- **- ----> GND (Ground)**

To LED (Prototype): This is a model to show how the connection with mains supply and bulb works.

Assumptions:

- Mains Supply - Power Bank (10000mAh)

- Bulb - LED

**Magnetic Door Sensor:**

One wire is connected to **GND** and the other connects to **D7**.

**LED:**

The anode (+, long leg) of the LED is connected to the digital I/O pin while the cathode (-, short leg) of the LED is connected to the Ground.

- **Red - D6**

- **Green - D5Software setup:Step 01: Installing Arduino IDE**

You will need Arduino IDE software to program your Arduino Uno.

**Step 02: Installing the Blynk app by Blynk Inc.**

In this project, I have used Blynk app to arm/disarm my magnetic door sensor.

## **Testing Your Model**

![Testing Your Model](https://content.instructables.com/ORIG/F5I/XMRO/JYG879BE/F5IXMROJYG879BE.jpg?auto=webp&frame=1&width=467&height=1024&fit=bounds&md=c67396478e30b217b0b77ae585c379d7)

To connect your Arduino UNo to Blynk application, tap on the play button and shortly afterwards you will see the message, 'Device is connected'.

How my model works:

- The Green LED will be lit up as long as the Arduino Uno R3 is connected to a power supply even when the magnetic door sensor is disarmed.

- When the magnetic door sensor is armed, and the door is opened, the Red LED lights up and the relay module is switched on.

- When the magnetic door sensor is disarmed while the door is opened, both the Red LED and Relay module are switched off, and the Green LED lights up.

---

Source: https://maker.wiznet.io/nagamma06/projects/controlling-light-bulb-in-your-room-using-mc-38-wired-magnetic-door-sensor/
