The working principle of the Hall sensor is based on the Hall effect proposed by Edwin Hall in 1869. The proposed statement says: “The Hall effect is the production of a voltage difference (the Hall voltage) across an electrical conductor, transverse to the current in the conductor and an applied magnetic field perpendicular to the current.”
So, what can be the simplest form of statement to understand it in a better way? In this book, it will be explained step by step with practical examples. The hall sensor will be interfaced with an At mega 16 microcontroller and an LED will be used to show the effect when a magnet will be brought near the hall sensor.

What is the Hall Effect?
The Hall effect is related to moving charges in a magnetic field. To understand in a practical way, connect a battery to a conductor as shown in the figure below (a). Current (i) will start flowing from the conductor through the positive terminal of the battery to the negative terminal.

The flow of electrons (e-) will be in the opposite direction of the current, i.e. from the negative terminal of the battery through the conductor to the positive terminal of the battery. At the moment we measure the voltage between the conductors, as shown in the image (b) below, then the voltage will be zero, i.e. the potential difference will be zero.

Now take a magnet and create a magnetic field between the conductors as shown in figure (c) below.

In this case, when the voltage is measured on the conductor, some voltage will be generated. This generated voltage is called “Hall voltage” and this phenomenon is called “Hall effect”.
We use Hall sensors with many microcontrollers to build interesting applications like speedometers, door alarms, virtual reality, etc.
Required Components
● A3144 Hall sensor
● Atmega16 microcontroller
● 16Mhz crystal oscillator
● Button
● Jumper
● Breadboard
● USBASP v2.0
Circuit Schematic

Programming Atmega16 for Hall Sensor
Atmega16 is programmed using USBASP and Atmel Studio 7.0. The complete program code is given at the end of this article. Just upload the program on Atmega16 using a JTAG programmer and Atmel Studio 7.0.
Programming the Atmega16 is simple and only two PORT pins are used. One PORT pin will be used to get the readings from the Hall sensor. The other PORT pin will be used to connect an LED. First, include all the required libraries in the program.
Defines the input pin for the Hall sensor reading.
Here the Hall sensor is connected to PORTA0 of Atmega16 and this pin is initialized for reading the status.
If magnet is near sensor then turn on LED or turn off LED. Detect state change based on PORT pin.
Application of Hall Sensor
Hall sensors are widely used wherever there is a need to measure the strength of a magnetic field or detect the poles of a magnet. Apart from this, there are many more applications where they can be found. Some of the applications are listed below:
● As proximity sensor in mobile phones
● Gear shifting mechanism in automobiles
● Rotary Hall Effect Sensor
● Check materials such as pipes and ducts
● Speed detection
Code
The complete code used in this article is as follows:
main (4)



