Arduino(22): Hall Effect Sensor

Hall effect-related applications are very extensive. I went to the blood donation center last week to donate blood. When I went to the bathroom, the door latch when the door closed was a Hall effect device. When the door was closed, the outside "toilet in use" light turned on. Another application is my bicycle speedometer. There is an induction magnet installed on the spokes in the rim, the frame supported by the axle, and a device similar to a wireless transmitter is installed to send the sensed result to the handle. This is also one of the applications of Hall effect.

Hall effect (Hall effect) refers to the phenomenon that when a solid conductor is placed in a magnetic field and current passes through, the charge carriers in the conductor are biased to one side by the Lorentz force, and then a voltage (Hall voltage) is generated. The electric field force caused by the voltage will balance the Lorentz force. Through the polarity of the Hall voltage, it can be confirmed that the current inside the conductor is caused by the movement of negatively charged particles (free electrons). The Hall effect was discovered by Edwin Herbert Hall in 1879. [ Wikipedia ] Hall-effect sensors are commonly used to detect the presence of magnets, and to make counters, tachometers, and anti-theft alarms. Let's take a look at how to implement the application of Hall effect sensor.


[Material]

  • Arduino Uno x 1
  • Hall effect sensor x 1
  • LED x1
  • 220 ohm resistor x1
  • Buzzer x1
  • Breadboard x1
  • Wires x N

[Wiring diagram]

ArduinoHall effect sensorother
+5VVCC-
GNDGND-
D2OUT-
D4-The buzzer is positive and the other end is grounded.
D5-The anode of the red LED is connected to a 220 ohm resistor, and the other end of the resistor is grounded.


[Code]

The device is equipped with an LED and a buzzer. When the Hall-effect sensing module detects the magnetic effect of the magnet and the potential changes to 1, it will light up the LED and the buzzer will sound.
int hallSensorPin = 2;     //Hall effect sensor pin
int ledPin=5;
int buzz=4; 
int state = 0;          

void setup() {
  pinMode(ledPin, OUTPUT);      
  pinMode(hallSensorPin, INPUT);     
  pinMode(buzz, OUTPUT);  
  Serial.begin(9600);    
}
void loop(){

  state = digitalRead(hallSensorPin);
  if (state == LOW) {        // When the magnet is close, it is detected that the sensor value of the module becomes low
  digitalWrite(ledPin, HIGH); 
    digitalWrite(buzz,HIGH);
    Serial.println("Digital value : HIGH");      
  } 
  else {
    digitalWrite(ledPin, LOW); 
    digitalWrite(buzz,LOW);      
    Serial.println("Digital value : LOW");
  }
  delay(100);  
}

[Result]




[Reference]


Post a Comment

Previous Post Next Post