Linear magnetic Hall sensor (KY-024) [S048]



https://www.youtube.com/watch?v=pdz_F2jL71A


*GitHub https://github.com/rdiot/rdiot-s048.git



* Specs

Linear Hall magnetic module and a digital interface, built-in 13 LED build a simple circuit to produce a magnetic field warning lamp 13 comes with digital interfaces of the LED, the linear Hall sensor magnetometer access number 3 interface, when linear Hall magnetometer Sensor senses a key signal, LED lights, otherwise off.


* Contents

- Connect

: Analog 

A0 ----- A0


G ----- GND

+ ----- 5V

D0 ----- X

 

: Digital

A0 ----- X

G ----- GND

+ ----- 5V

D0 ----- D2 



- Key Code

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>


LiquidCrystal_I2C lcd(0x27,20,4);  // LCD2004

int pin = A0;


void setup()

{

  lcd.init();  // initialize the lcd 

  lcd.backlight();

  lcd.print("start LCD2004");


  pinMode(pin,INPUT);

  delay(1000);


  lcd.clear();

}


void loop()

{

 

  lcd.setCursor(0,0);

  lcd.print("S048:Linear Mag Hall");


  int val = analogRead(pin);


  lcd.setCursor(0,1);

  lcd.print("val=" + (String)val + "  ");


  if(val >= 527 && val <= 528)

  {

    lcd.setCursor(0,2);

    lcd.print("nomally = 527~528");    

  }

  else if (val < 527)

  {

    lcd.setCursor(0,2);

    lcd.print("under 527 : N     ");    

  }

  else if (val > 528)

  { 

    lcd.setCursor(0,2);

    lcd.print("over 527 : S      ");       

  }

  delay(200);

}

Posted by RD IoT RDIoT

댓글을 달아 주세요