• +965 51122049
Hall magnetic sensor module

Hall magnetic sensor module

KWD0.500KWD0.500
0%Off

Hall magnetic sensor module


 

 


Share:

This is a magnetic switch. If no magnetic field is present, the signal line of the sensor is HIGH (3.5 V). If a magnetic field is presented to the sensor, the signal line goes LOW, at the same time the LED on the sensor lights up.

The polarity of the magnetic field is of influence to the switching action.

 

The front side of the sensor needs the opposite polarity as the back of the sensor to switch on.

In the example program the led on the Arduino (pin 13) will be turned on when a magnetic field is present.

Connecting to the Arduino

  • Pin - = GND, connect to GND of the Arduino
  • Pin (middle pin) +5 v, connect to Arduino +5
  • Pin S signal, connect to Arduino pin 10
  • Power consumption, 3 mA in rest, 8 mA when switched on

Example code

/*
KY-003 Hall magnetic switch
*/
	
	
	
	
	
	
	
	
 
int
	
	
	
	
	
	
	
	 Led =
	
	
	
	
	
	
	
	 13
	
	
	
	
	
	
	
	 ;
	
	
	
	
	
	
	
	 // define LED Interface
	
	
	
	
	
	
	
	
int
	
	
	
	
	
	
	
	 SENSOR =
	
	
	
	
	
	
	
	 10
	
	
	
	
	
	
	
	 ;
	
	
	
	
	
	
	
	 // define the Hall magnetic sensor interface
	
	
	
	
	
	
	
	
int
	
	
	
	
	
	
	
	 val ;
	
	
	
	
	
	
	
	 // define numeric variables val
	
	
	
	
	
	
	
	
 
void
	
	
	
	
	
	
	
	 setup ()
	
	
	
	
	
	
	
	
{
	
	
	
	
	
	
	
	
  pinMode (
	
	
	
	
	
	
	
	Led,
	
	
	
	
	
	
	
	 OUTPUT)
	
	
	
	
	
	
	
	 ;
	
	
	
	
	
	
	
	    // define LED as output interface
	
	
	
	
	
	
	
	
  pinMode (
	
	
	
	
	
	
	
	SENSOR,
	
	
	
	
	
	
	
	 INPUT)
	
	
	
	
	
	
	
	 ;
	
	
	
	
	
	
	
	  // define the Hall magnetic sensor line as input
	
	
	
	
	
	
	
	
}
	
	
	
	
	
	
	
	
 
void
	
	
	
	
	
	
	
	 loop ()
	
	
	
	
	
	
	
	
{
	
	
	
	
	
	
	
	
  val =
	
	
	
	
	
	
	
	 digitalRead (
	
	
	
	
	
	
	
	SENSOR)
	
	
	
	
	
	
	
	 ;
	
	
	
	
	
	
	
	 // read sensor line
	
	
	
	
	
	
	
	
  if
	
	
	
	
	
	
	
	 (
	
	
	
	
	
	
	
	val ==
	
	
	
	
	
	
	
	 LOW)
	
	
	
	
	
	
	
	 // when the Hall sensor detects a magnetic field, Arduino LED lights up
	
	
	
	
	
	
	
	
  {
	
	
	
	
	
	
	
	
    digitalWrite (
	
	
	
	
	
	
	
	Led,
	
	
	
	
	
	
	
	 HIGH)
	
	
	
	
	
	
	
	;
	
	
	
	
	
	
	
	
  }
	
	
	
	
	
	
	
	
  {
	
	
	
	
	
	
	
	
    digitalWrite (
	
	
	
	
	
	
	
	Led,
	
	
	
	
	
	
	
	 LOW)
	
	
	
	
	
	
	
	;
	
	
	
	
	
	
	
	
  }
	
	
	
	
	
	
	
	
}
	
	
	
	
	
	
	
	

Add your review

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

Please login to write review!

Upload photos

Looks like there are no reviews yet.

Related Products