KY003 Magnetic Hall Sensor Module How To Project (AZ Delivery 35 in 1 sensor kit)
Автор: Electronics Loop
Загружено: 13 февр. 2022 г.
Просмотров: 1 326 просмотров
KY003 Magnetic Hall Sensor Module How To Project
You can buy this sensor separately or in a kit. Ours was in a AZ Delivery 35 in 1 sensor kit.
If you want to try out the KY003 Magnetic sensor the code I used is below for you to copy and paste and get started quickly.
void setup() {
// next 4 lines only because of my cheat to plug direct into arduino
pinMode(4,OUTPUT);
digitalWrite(4,LOW); //cheat instead of connecting to 0v
pinMode(3,OUTPUT);
digitalWrite(3,HIGH); // cheat instead of connecting to 5v
// with VCC and GND hardwired you would start here
pinMode(2,INPUT); // terminal marked S
pinMode(13,OUTPUT); // output indication - onboard LED
Serial.begin(9600); // initialise serial for debugging
}
void loop() {
// read the sensor
int ky003Value;
ky003Value = digitalRead(2); // grab the input - pin marked S
// note output is open collector
// however the LED and series resistor acts as a pull up
// without these set pinMode 2 to INPUT_PULLUP
// True = OFF = No Field
// False = ON = Field detected
if(ky003Value) {
Serial.println("NO FIELD");
digitalWrite(13,LOW);
} else {
Serial.println("MAGNETIC FIELD PRESENT");
digitalWrite(13,HIGH);
}
delay(500);
}
#arduino #arduinoproject

Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: