د آردوینو کوډ او ویډیو د KY-024 هال سینسر ماډل لپاره
په دې ټیوټوریل کې، موږ به وپلټو چې څنګه د KY-024 هال سینسر ماډل د Arduino سره وکاروو ترڅو مقناطیسي ساحې کشف کړو. هال سینسر به د یوې کړنې د پیلولو لپاره وکارول شي کله چې دا مقناطیسي ساحه کشف کړي، او موږ به پایلې په سریال مانیټر کې ښکاره کړو. پایله ستاسو په پروژو کې د مقناطیسي سینسنګ د یوځای کولو یوه ساده مګر اغیزمنه لار ده، چې تاسو ته د نور پراختیا لپاره بنسټ درکوي. د لا زیاتو تفصیلي توضیحاتو لپاره، ډاډ ترلاسه کړئ چې ویډیو وګورئ (په ویډیو کې په 00:00 کې).


هارډویر تشریح شوی
د هال سینسر ماډل د مقناطیسي ساحو د کشف لپاره ډیزاین شوی او په بیلابیلو غوښتنلیکونو کې په عام ډول کارول کیږي، پشمول د نږدېوالي سینسنګ او د سرعت کشف. کله چې مقناطیسي ساحه شتون ولري، سینسر یو سیګنال تولیدوي چې د Arduino لخوا لوستل کیدی شي. دا Arduino ته اجازه ورکوي چې پوه شي کله چې د مقناطیسي ساحې سره یو شی نږدې وي.
په دې پروژه کې، موږ به د کړنې وسیلې په توګه یو بزر هم وکاروو. کله چې هال سینسر مقناطیسي ساحه کشف کړي، Arduino به بزر فعال کړي ترڅو د اوریدو وړ خبرتیا چمتو کړي. اصلي برخې چې پکې شاملې دي هال سینسر، د Arduino بورډ، او بزر دي.
د ډیټاشیټ تفصیلات
| جوړونکی | Honeywell |
|---|---|
| د پرزې شمېره | SS495A1 |
| د منطق/IO ولټاژ | 4.5 – 10 V |
| د بریښنا رسولو ولټاژ | 4.5 – 10 V |
| د تولید جریان (په هر چینل) | 20 mA اعظمي |
| د لوړ جریان (په هر چینل) | 50 mA اعظمي |
| د PWM فریکونسۍ لارښود | N/A |
| د منطق داخلیدو حدونه | 0.7 V (لوړ)، 0.3 V (ټیټ) |
| د ولټاژ کمښت / RDS(on) / سنتریشن | 0.4 V اعظمي |
| حرارتي حدونه | -40 تر +85 °C |
| بسته | TO-92 |
| یادښتونه / بیلابیل ډولونه | په بیلابیلو حساسیتونو کې شتون لري |
- د ټاکل شوي ولټاژ حد دننه د مناسب بریښنا رسولو ډاډ ترلاسه کړئ.
- د ماډل د زیان رسولو څخه مخنیوي لپاره د تولید جریان حدونو ته پام وکړئ.
- د باثباته لوستلو لپاره که اړتیا وي د پل-اپ ریزسټر وکاروئ.
- سینسر د قوي بریښنایی مقناطیسي ساحو څخه لرې وساتئ چې ممکن مداخله رامینځته کړي.
- سینسر د ځانګړي غوښتنلیک اړتیاو سره سم کیلیبریټ کړئ.
د تارونو لارښوونې


د هال سینسر ماډل د Arduino سره د تار کولو لپاره، لومړی د سینسر د VCC پن د بریښنا لپاره د Arduino د 5V پن سره وصل کړئ. بیا د سرکټ بشپړولو لپاره د GND پن د Arduino د GND پن سره وصل کړئ. د هال سینسر د تولید پن، چې معمولا د OUT په توګه نښه شوی، باید په Arduino کې ډیجیټل پن 2 سره وصل شي.
د بزر لپاره، مثبت ترمینل په Arduino کې ډیجیټل پن 8 سره وصل کړئ، او منفي ترمینل د GND سره وصل کړئ. دا ترتیب Arduino ته اجازه ورکوي چې د سینسر تولید ولولي او کله چې مقناطیسي ساحه کشف شي بزر فعال کړي.

د کوډ مثالونه او واک ترو
لاندې کوډ هال سینسر او بزر پیل کوي. دا د سینسر او کړنې لپاره پنونه تعریفوي. اصلي لوپ د سینسر حالت لولي او د هغې مطابق بزر فعالوي.
#define DETECT 2 // د سینسر لپاره پن 2
#define ACTION 8 // د یو څه کولو لپاره د کړنې پن 8
void setup() {
Serial.begin(9600);
pinMode(DETECT, INPUT); // د کشف داخلیدو پن تعریف کړئ
pinMode(ACTION, OUTPUT); // د ACTION تولید پن تعریف کړئ
}
په دې کوډ کې، د DETECT متغیر پن 2 ته ټاکل شوی، کوم چې د سینسر لوستلو لپاره کارول کیږي. د ACTION متغیر پن 8 ته ټاکل شوی، چیرې چې بزر وصل دی. د setup فنکشن سریال اړیکه پیل کوي او د پن حالتونه ټاکي.


void loop() {
int detected = digitalRead(DETECT); // د هال سینسر ولولئ
if (detected == LOW) {
digitalWrite(ACTION, HIGH); // بزر آن کړئ
Serial.println("Detected!");
} else {
digitalWrite(ACTION, LOW); // بزر بند کړئ
Serial.println("Nothing");
}
delay(200);
}
د کوډ دا برخه په دوامداره توګه د هال سینسر حالت ګوري. که سینسر مقناطیسي ساحه کشف کړي (کله چې detected LOW وي)، دا بزر آن کوي او په سریال مانیټر کې "Detected!" چاپوي. که هیڅ ساحه ونه موندل شي، دا بزر بندوي او "Nothing" چاپوي.
ښودنه / څه تمه وکړو
کله چې تاسو کوډ پرمخ وړئ، Arduino به په دوامداره توګه د هرې مقناطیسي ساحې لپاره هال سینسر څاري. که مقناطیسي ساحه کشف شي، بزر به غږ وکړي، او تاسو به په سریال مانیټر کې "Detected!" وګورئ. که مقناطیسي ساحه شتون ونلري، بزر به بند پاتې شي، او "Nothing" به ښکاره شي. د تارونو سره محتاط اوسئ ترڅو د بیرته راګرځیدلو اړیکو څخه مخنیوی وشي، کوم چې کولی شي د کشف ناکامۍ لامل شي (په ویډیو کې په 06:15 کې).
د ویډیو وخت نښې
- 00:00 - د هال سینسر ماډل پیژندنه
- 02:30 - د تارونو تشریح
- 05:00 - د کوډ واک ترو
- 08:15 - ښودنه
/*
* This is the Arduino code for a Hall Sensor module for Arduino.
// Written for Robojax.com video
* A Hall sensor switch will detect the magnetic field, and the module is used to trigger something.
* Watch the video for details: https://youtu.be/QH1Lw9BwTJI
* Code is available at: http://robojax.com/learn/arduino
*
Written by Ahmad Nejrabi for Robojax.com
on January 28, 2018 at 19:41 in Ajax, Ontario, Canada
* Permission granted to share this code, given that this
* note is kept with the code.
* Disclaimer: This code is "AS IS" and for educational purposes only.
*
*/
/*
*/
// Hall Sensor code for Robojax.com
#define DETECT 2 // pin 2 for sensor
#define ACTION 8 // pin 8 for action to do something
void setup() {
Serial.begin(9600);
Serial.println("Robojax.com Hall Module Test");
pinMode(DETECT, INPUT);//define detect input pin
pinMode(ACTION, OUTPUT);//define ACTION output pin
// Flame sensor code for Robojax.com
}
void loop() {
// Hall Sensor code for Robojax.com
int detected = digitalRead(DETECT);// read Hall sensor
int detectedAn = analogRead(A0);// read flame analog value
if( detected == LOW)
{
digitalWrite(ACTION,HIGH);// set the buzzer ON
Serial.println("Detected!");
// Serial.println(detectedAn);// print analog value
}else{
digitalWrite(ACTION,LOW); // Set the buzzer OFF
Serial.println("Nothing");
// Hall Sensor code for Robojax.com
}
delay(200);
}
Things you might need
-
Amazon
-
Amazon
-
Amazon
-
AliExpressBuy KY-024 Linear Magnetic Hall Switch from AliExpresss.click.aliexpress.com
-
AliExpressBuy KY-024 Linear Magnetic Hall Switch from AliExpress (2)s.click.aliexpress.com
Resources & references
-
ExternalHall Sensor Datasheet (PDF)elecrow.com
Files📁
Datasheet (pdf)
-
SS49E_SS39ET_SS59ET_hall_sensor_honeywell_49EThe SS39ET/SS49E/SS59ET Series low-cost linear Hall-effect sensor ICs are small, versatile devices that are operated by the magnetic field from a permanent magnet or an electromagnet. They are designed and manufactured for cost competitiveness. The linear sourcing output voltage is set by the supply voltage and varies in proportion to the strength of the magnetic field. Low voltage capability as low as 2.7 Vdc and reduced current consumption of only 6 mA typically at 5 Vdc help make this product energy efficient. The integrated circuitry features low noise output, which makes it unnecessary to use external filtering. These sensor ICs Interface with many electrical components without buffering. They also include thin film resistors to provide increased temperature stability and accuracy. These linear Hall-effect sensor ICs have an operating temperature range of -40 °C to 100°C [-40 °F to 212 °F], appropriate for industrial and medical environments. Thermal balancing allows for stable operation over the full temperature range. They are available in three package styles, all of which may be supplied on tape for automated, lower-cost assembly: • SOT-23: SS39ET. This small footprint takes up less space on the PC board, typically allowing for more components. • Flat TO-92-style, with different lead configurations: SS49E, SS49E-L, SS49E-F. • SOT-89B: SS59ET.
SS49E_SS39ET_hall_sensor_honeywell_49E.pdf0.98 MB -
49E YANGZHOU Hall-effect linear hall sensorThe 49E Series Economical Linear Hall-effect sensors are small, versatile linear Hall-effect devices that are operated by the magnetic field from a permanent magnet or an electromagnet. The linear sourcing output voltage is set by the supply voltage and varies in proportion to the strength of the magnetic field. The integrated circuitry features low noise output, which makes it unnecessary to use external filtering. It also includes thin film resistors to provide increased temperature stability and accuracy. These linear Hall sensors have an operating temperature range of -40 °C to 100 °C, appropriate for commercial, consumer, and industrial environments.
49E_YANGZHOU_Hall-effect_linear_hall_sensor.pdf0.49 MB -
SS49E SS39ET Hall Sensor Honeywell 49EDatasheet for Honeywell SS49E and SS39ET linear Hall-effect sensor ICs. These sensors provide analog output proportional to magnetic flux density, operate from 4.5V to 10.5V, and are available in a small SIP package.
SS49E_SS39ET_hall_sensor_honeywell_49E.pdf0.98 MB