Hall

A Hall sensor creates a voltage related to the magnetic field around the sensor. This can be used to detect distance from a nearby magnet. Hall sensors can also be used to detect the magnetic field induced in a wire or coil.

Input: This module outputs 5v when a magnetic field (e.g. a human body) is close to the sensor, and roughly 0v when there is nothing nearby. When connected to an input on the Arduino using the TinkerKit Shield, you can see values between 0 (no presence) and 1023 (presence detected).

Module description: An Hall Sensor is mounted on a standard TinkerKit board; on the back of the module you can find a signal amplifier, a green LED that signals that the module is correctly powered and a yellow LED whose brightness depends on the values output by the module.

In the quiescent state (no sig-nificant magnetic field: B = 0), the output is one half of the supplied voltage. Once there’s a magnetic field perpendicular to the sensor’s surface, when there’s the SOUTH side exposed, the output grows above the quiescent output voltage, when NORTH, below the quiescent output voltage.

The sensor’s sensitivity is 1.3 mV/G

NB: There are exposed electrical contacts on the sensor surface – be careful to not touch the board with metallic objects, you may cause a short.

Available methods

TKHallSensor hs(I0);
read() return the thermistor reading. It is an analog value from 0 to 1023
polarity() return two values: NORTH if is reading a magnetic field that is most in the north pole polarity, SOUTH is if is

 

// include the TinkerKit library
#include <TinkerKit.h>

// creating the object 'hs' that belongs to the 'TKHallSensor' class 
TKHallSensor hs(I0);	

// creating the object 'led' that belongs to the 'TKLed' class 
TKLed led(O0);		

void setup()
{
  // initialize serial communications at 9600 bps
  Serial.begin(9600);
}

void loop()
{
  // Read the analog value of the Hall Sensor and print on the serial monitor
  Serial.print("Hall Sensor Value = ");                      
  Serial.println(hs.read());

  // with polarity() we can know if the magnetic field 
  // is going to NORTH or SOUTH without read the analog value
  if (hs.polarity() == NORTH) {
    led.on();
  }
  if (hs.polarity() == SOUTH) {
    led.off();
  }

  // wait 10 milliseconds before the next loop:
  delay(10);  
}