hall sensor with arduino

hello

i want to detect hall sensor

this is my code

const int hallPin = 2; // the number of the hall effect sensor pin
int hallState = 0; // variable for reading the hall sensor status
volatile byte half_revolutions;

void setup() {
Serial.begin(115200);
pinMode(hallPin, INPUT);

// initialize the hall effect sensor pin as an input:

}

void loop(){
// read the state of the hall effect sensor:
hallState = digitalRead(hallPin);

if (hallState == LOW) {
half_revolutions++;
Serial.println(“detect”);
}

}

and this is my board

i want to your help

홀브레드.PNG

void loop()
{
  while (digitalRead(hallPin)); // wait till low
  half_revolutions++;
  Serial.println("detect");
  while (!digitalRead(hallPin)); // wait till high
}