Surilli
Published © LGPL

Detect Magnetic Field Using Mini Read Sensor (KY-021)

It works when magnetic field is present. It is used in 'pick ups' on bicycle computers and the sensors on window and door alarms.

BeginnerFull instructions provided9 minutes747
Detect Magnetic Field Using Mini Read Sensor (KY-021)

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
×3
Breadboard (generic)
Breadboard (generic)
×1
Surilli WiFi
Surilli WiFi
×1
LED (generic)
LED (generic)
×1
Reed switch KY-021
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

reed_I15KE7XVjt.fzz

Code

Untitled file

C/C++
int Led = 5 ;// define LED Interface
int buttonpin = 4; // define the Reed sensor interfaces
int val ;// define numeric variables val
void setup ()
{
  pinMode (Led, OUTPUT) ;// define LED as output interface
  pinMode (buttonpin, INPUT) ;// output interface as defined Reed sensor
}
void loop ()
{
  val = digitalRead (buttonpin) ;// digital interface will be assigned a value of 3 to read val
  if (val == HIGH) // When the Reed sensor detects a signal, LED flashes
  {
    digitalWrite (Led, LOW);
  }
  else
  {
    digitalWrite (Led, HIGH);
  }
}

Credits

Surilli

Surilli

196 projects • 62 followers
Surilli is a premiere Internet of Things centric Technology Company aimed at providing cutting edge innovative solutions.

Comments