Loading
Loading
IoT Lab content is currently available in Arabic only. We're working on an English version.
عرض بالعربية →Measuring speed and magnetic fields.
VCC, GND, and digital/analog output.
const int hallPin = 2;
void setup() {
Serial.begin(9600);
pinMode(hallPin, INPUT);
}
void loop() {
if(digitalRead(hallPin) == LOW) {
Serial.println("Magnet Detected!");
}
delay(100);
}Approaching the sensor with the wrong magnetic pole — most Hall sensors are sensitive to only one pole (either South or North).