Example Code for Arduino-MindPlus Analog Read

When the Hall circuit faces the S pole of the magnet, the analog value gradually increases. Conversely, when facing the N pole of the magnet, the analog value gradually decreases.

Hardware Preparation

  • 1 x Arduino UNO
  • 1 x I/O Expansion Shield V7.1
  • 1 x Linear/Analog Hall Sensor
  • 1 x LED Light
  • 1 x Digital Connection Cable

Software Preparation

- MindPlus

Wiring Diagram

Sample Code

Result

When a magnet's South pole is facing the sensor detection area, the indicator light on the sensor illuminates, and the analog output value is greater than 512. When a magnet's North pole is facing the sensor detection area, the indicator light on the sensor illuminates, and the analog output value is less than 512. (When no magnetic pole is detected, the analog value is between 500-520.)

Detected South Pole Magnet Detected North Pole Magnet
Effect Display
Serial Output

Was this article helpful?

TOP