Tags: RobotDyn, Hall, effect, magnetic, sensor, Analog, Digital, Arduino,

Hall effect magnetic sensor with Analog and Digital outs for Arduino

  • 5.00 AED
    • Ex Tax:5.00 AED
    • Brands RobotDyn
    • Product Code: 256
    • Availability: In Stock
    The Hall Effect Magnetic Sensor can be used for detect the presence (or absence!) of nearby objects such as magnets.If no magnetic field is present, the signal line of the sensor is HIGH (on digital out). If a magnetic field is presented to the sensor, the signal line goes LOW (on digital out), at t..

    The Hall Effect Magnetic Sensor can be used for detect the presence (or absence!) of nearby objects such as magnets.
    If no magnetic field is present, the signal line of the sensor is HIGH (on digital out). If a magnetic field is presented to the sensor, the signal line goes LOW (on digital out), at the same time the LED (blue) on the sensor lights up. 
    The distance detection to a magnetic object can be adjusted via the potentiometer on board.
    It also has the Analog output, to determine the magnitude of a magnetic field or the distance to a object.
    The polarity of the magnetic field is of influence to the switching action. The front side of the sensor needs the opposite polarity as the back of the sensor to switch on.



    This Tutorial is How to connect Hall effect magnetic sensor with  Arduino :


    In this video tutorial you will how the hall effect sensor is interfaced with arduino and how it can be programmed to control an output load. This Tutorial covers the interfacing , programming and testing. A very basic tutorial about the Hall effect sensor.


     Example for Hall effect magnetic sensor Code

    The following Arduino sketch will read values from both digital and analog interfaces on the Sensor  The digital interface will turn on the Arduino's LED when a magnetic field is detected.

    The analog interface starts at an initial value determined by the input voltage and the potentiometer, this value will increase or decrease depending on the intensity and polarity of the magnetic field.

     

    int led = 13 ; // LED on arduino
    int digitalPin = 3; // linear Hall magnetic sensor digital interface
    int analogPin = A0; // linear Hall magnetic sensor analog interface
    int digitalVal ; // digital readings
    int analogVal; // analog readings
    
    void setup ()
    {
      pinMode (led, OUTPUT); 
      pinMode (digitalPin, INPUT); 
      //pinMode(analogPin, INPUT); 
      Serial.begin(9600);
    }
    
    void loop ()
    {
      // Read the digital interface
      digitalVal = digitalRead(digitalPin) ; 
      if (digitalVal == HIGH) // When magnetic field is present, Arduino LED is on
      {
        digitalWrite (led, HIGH);
      }
      else
      {
        digitalWrite (led, LOW);
      }
      
      // Read the analog interface
      analogVal = analogRead(analogPin);
      Serial.println(analogVal); // print analog value
    
      delay(100);
    }

     

    Setting analog pin as input (line 11) is not necessary, the analogRead() function will automatically set the pin as analog input when used.

    Use Tools > Serial Plotter on the Arduino IDE to visualize the changes on intensity and polarity of the magnetic field.

    KY-024 arduino output on serial

    There are no reviews for this product.

    Write a review

    Please login or register to review