Please note: Currently trying to set up a hall effect sensor for the wheel speed of a car. Eventually we will have discs with teeth to produce a good signal but currently just using a lump of metal and mr arm to generate the signal. Using UNO R3
So what I have so far is a hall effect sensor that outputs an analogue signal and I have managed to read this and convert it to a 1 or 0 stored in a variable "hallval". The led part is just so I can see it working.
int hallPin = A0;
int ledPin = 13;
val = analogRead(hallPin);
if (val <= 75) digitalWrite(ledPin, HIGH);
else if (val > 75) digitalWrite(ledPin, LOW);
if (val <= 75) hallval = 1;
else if (val > 75) hallval = 0;
What I need to do, or think I need to do is now measure the time it takes to switch "hallval" from 1 to the next "1" in order to calculate the speed.
So I have two questions, given that this is the sensor I have right now and cannot buy new ones.. yet.
1) Is what I have done so far good enough / does anyone know an easier way to achieve what I require?
2) How can I measure the time from 1 to the next 1? are there any functions you can suggest the might help me.