That sensor is a Hall effect device.
Did you use a pull up resistor with it?
What are you interfacing to?
Would you rather use a reed switch? (Two wire magnetic dry contact).
Thank you for the answer and forgiveness for the delay!
I have come a long way and I think I have solved my problems.
First of all I modified the file endstop.h:
I replaced pinMode (_pin, INPUT);
by pinMode (_pin, INPUT_PULLUP);
In addition I remember (Iām a beginner!) It was necessary to put the magnet in a certain direction for the sensor to work. For that I used the program:
int pinSensor = 4;
void setup () {
pinMode (pinSensor, INPUT_PULLUP);*
Serial.begin (9600);* }
void loop () {
int capt = digitalRead (pinSensor);*
Serial.println (capt); // Acrit 1 or 0*
if (capt == HIGH) {*
Serial.println ("HIGH SENSOR");*
}*
else {*
Serial.println ("LOW SENSOR");*
}* }
This allows me to check the state of the sensor and the direction of the magnet.
The magnet and the sensor were stuck on the rotator