Project showcase
Arduino - Magnetic Reed Switch KY-021

Arduino - Magnetic Reed Switch KY-021 © CC BY-SA

Hello world! Yep yep, I made another simple project. This time for the KY-021 Mini reed switch. It will simply turn on and off a lamp.

  • 4,606 views
  • 0 comments
  • 2 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
mini Reed Switch
×1
Channel Relay
×1
11026 02
Jumper wires (generic)
×1
Magnet
×1
Lamp + Power cable
×1

About this project

Hello world! Yep yep, I made another simple example project. This time for the KY-021 Mini reed switch. It will simply turn on and off a light with a relay by using a magnetic field. Reed switches are used a lot in burglar alarms.

Follow the next step for the Schematic Code & Parts List.

Step 1: Parts List.

Parts List

  • Arduino Uno, I used the robotdyn Uno. One with 7 analog pins! Very good stuff! Buy it!
  • A magnetic field, can be any magnet but it is best to use a small one. Or even better, a magnet from a alarm.
  • Set of jumper wires. MM/FF/MF
  • Lamp + power cable (optional, you don't need this!) The relay itself will show you if it works by turning on a led.

Good luck!

Code

KY-021_Mini_Reed_SWITCH.inoArduino
//Author: Danny van den Brande, arduinosensors.nl.
//Hello world! I made a simple example on the KY-021 mini reed switch.
//Do what ever you like with this code! This code will turn on a relay.
//In my video i used a lamp, but you can add any device to the relay if you want.
//reed switches can be used for a dozen of things but is mostly known for its use
//in burglar alarms, and work with a magnetic field.
int Relay = 9 ;
int MiniReed = 8; 

int val ;
void setup ()
{
  pinMode (Relay, OUTPUT);
  pinMode (MiniReed, INPUT);
}
void loop ()
{
  val = digitalRead (MiniReed) ;
  if (val == HIGH) 
  {
    digitalWrite (Relay, HIGH);
  }
  else
  {
    digitalWrite (Relay, LOW);
  }
}

Schematics

KY-021 Magnetic REED Switch schematic_bb.png
Ky 021%20magnetic%20reed%20switch%20schematic bb

Comments

Similar projects you might like

The Magnetic Field and RGB Tester

Project tutorial by Kutluhan Aktar

  • 3,545 views
  • 0 comments
  • 14 respects

The Troll Switch

Project tutorial by Aitor Gamarra

  • 1,002 views
  • 1 comment
  • 2 respects

Bluetooth Controlled Light Switch

Project showcase by Team The Instrumentation Crustaceans

  • 23,403 views
  • 4 comments
  • 26 respects

How to control your light switch from your smartphone?

Project in progress by Mahmoud Ahmed

  • 22,609 views
  • 3 comments
  • 15 respects

Wireless Magnetic Data Transfer

Project tutorial by Tomi Chen

  • 4,688 views
  • 4 comments
  • 18 respects
Add projectSign up / Login