Hall Effect Sensor 2


Introduction to the Hall Effect Sensor

Hall Effect SensorA hall effect switch is a component that provides an output based on the strength of a magnetic field.   This can be used for many applications, such as a simple alarm on a door or window.

More complex applications would include the speed or direction of a motor.   If a magnet is placed on a motor, as the motor is rotating, the hall effect sensor can be used to count pulses in a given amount of time.  This would determine the speed of a motor.  If two switches are placed near each other, we can also determine the direction of rotation.  We would just need for our program to detect which switch is made first to determine this direction.

Wiring Diagram

In oHall Effect Hookupur example, we will use the Hall Effect Sensor as a simple switch.   To wire this switch, we will assume the small side (front) is facing you.   The pin on the left, we will wire to 5v on our Uno board.   The pin in the middle will be our ground, and the pin on the right will be our signal, which we will connect to I/O pin 2 on our Uno board.

Notice that we are also placing a 10K resistor between the left and right pin to hold the input pin 2 high until a magnetic field is detected.  When a magnet is moved over the hall effect switch, the input will go low.

 

 

Using the code

To make this application work in it’s simplest form, we don’t need to write any code.   We can just use the button example that is in the Arduino software already.    Just click on File | Examples | Digital, and you will find the button example.   Before you upload, be sure your board is set correctly, and your communication port.

If you are using this sensor for more high speed applications (such a motor speed), you will want to read up on Interrupts.   When you configure an interrupt, the regular scan of the Arduino can be interrupted when the hall effect switch changes it’s value.   The code for your interrupt can then count the transition, then the processor can return to it’s regular scan cycle.   By using interrupts, your counts will not be near as dependent on the speed of the processor.

If you need help getting started with microprocessors, please see this page, which will help you get set up, or you can purchase the hall effect sensors from an online store, such as SparkFun!

— Ricky Bryce


Leave a comment

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

62 + = 68

2 thoughts on “Hall Effect Sensor

  • Tom

    Your website has a lot of good industrial/technical information. However, I find the insertion of religion off-putting. Understand that I don’t care what you or anyone else believes, but it seems odd to include such links on a website for technical information. If I was looking for religious guidance, I doubt I would be impressed by a link or information I found on a website highlighting computer parts.

    • ricky Post author

      Thank you Tom. I’m glad you like the information on the site. Always feel free to explore anything on the site that you wish. I’m always adding content.