hi guys
i am trying to get an "analograd" from a hall sensor, have a few here diferent types.
as digital read i get 0 or 1 thats ok, but what i want is to read the proximity of the magnet, how can this be done? the hall sensor space is critical as it will go in a very small place
thanks
the current code is this one, i have replaced digital with analog and it only toses some numbers
const int hallPin = 3; // the number of the hall effect sensor pin
const int ledPin = LED_BUILTIN; // the number of the LED pin
// variables will change:
int hallState = 0; // variable for reading the hall sensor status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the hall effect sensor pin as an input:
pinMode(hallPin, INPUT);
Serial.begin(9600);
}
void loop(){
// read the state of the hall effect sensor:
hallState = analogRead(hallPin); // testing
Serial.println(hallState);
}
What controller are You using? If it is an UNO reading the pin the way You do will give just "0" or "1".
Try connecting the Hall sensor to an analog input like A0, A1..... and run Your sketch. Declare hallPin as "A0".
@Wawa
Thanks!
I think compilers are suspect resources. One never knows what they will do.... Some 45 years ago the Gothenburg University Computer Central set up a compiler test team, in order to keep key-happy students away from taking over the entire IBM360, using a bug in the "set priority function".... The entire system including the registers for the entire University was in the hands of some students.
What came out of the project I don't know.
hi
thanks for all the info
have tested it, i do get analog readings now but still all or nothing, i dont get a modulation...progressive increase and decrease as magnet is close or further of
Google tells me that the first one could be a switch (digital).
The second one is a phone number.
The third one could be the one with an analogue output.
Leo..
I picked up a project from somewhere that used a Hall sensor and an electro magnet in order to keep a load floating in the air. That sensor was definatly an analog Hall sensor. Maybe there are digital ones too.
You replied in #2 but is that the name of the sensor? It looks like some companies partnumbers.
hi Thanks
this has worked! now i get reading depending on the magnets position
i have notices if i leave it reading (test done without magnet) the values tend to creep up, once magnet is on and off the value gets back to its initial value and then creeps up again, how can i avoid this? in the hall circuit a resistor is provided.
Greate! Maybe You can Google about the fundamentals, basics etc. about Hall sensors? Hopefully some more experienced helper pops up and tells what it’s all about.
Danny1000:
in the hall circuit a resistor is provided.
Why?
That might be needed for a digital (switch) hall sensor with open collector, but not for this analogue one.
Did you have to change that '512' value, to get it to print about zero without a magnet near?
And is that zero point drifting.
By how much, and in what time frame.
Danny1000:
once magnet is on and off...
What do you mean with that.
Are you using an electro magnet?
Leo..