This example is for Wiring version 0027+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.
Hall sensor by Juan Guillermo (Coco) Gomez
A hall sensor is a magnetic field sensor, it can detect when a magnet is in the proximity. This example turns on the Wiring board LED when a magnet is near the Hall sensor
int pinHall = 0; // Pin for the Hall sensor
void setup()
{
pinMode(48, OUTPUT); // sets the digital pin as output
pinMode(pinHall, INPUT); // sets the digital pin as input
}
void loop()
{
if (digitalRead(pinHall) == HIGH) // If a magnet is near the Hall sensor
{
digitalWrite(48, HIGH); // turns ON the LED
} else {
digitalWrite(48, LOW); // turn OFF the LED
}
}