Objective
Learn how to use a Hall Effect sensor to detect the presence of a magnetic field and display the results using Arduino.
Required Components
- Hall Effect Sensor
- Arduino Board (e.g., Arduino Uno)
- Jumper wires
- Breadboard
- Arduino IDE (for programming)
Working Principle
The Hall Effect sensor produces an output voltage when exposed to a magnetic field, enabling detection and measurement of the field's presence.
Circuit Diagram
Arduino Code
const int hallPin = 2; // Hall Effect sensor connected to digital pin 2
int hallState = 0;
void setup() {
Serial.begin(9600); // Initialize serial communication
pinMode(hallPin, INPUT); // Set the Hall Effect sensor pin as input
}
void loop() {
hallState = digitalRead(hallPin); // Read the sensor state
if (hallState == HIGH) {
Serial.println("Magnetic Field Detected!");
} else {
Serial.println("No Magnetic Field.");
}
delay(1000); // Wait for 1 second before the next reading
}
Results
The Arduino serial monitor will display either "Magnetic Field Detected!" or "No Magnetic Field," depending on the sensor's state.
Applications
- Magnetic field detection
- Position sensing
- Speed measurement in motors
Conclusion
Hall Effect sensors are highly useful for detecting and measuring magnetic fields in a wide range of applications.