What am I doing wrong??

I’m trying to set up some wiring so that i can get a signal (that eventually will cause a servo arm to rotate) when the ends of two wires are touched. What I have is:
(two AAA batteries with the negative lead into ground in my board and the positive lead touching [or not touching] a wire connected to analog input pin 5)

and my code is:

#include <Servo.h>
const int sensor_pin = A5;
int val;
int small;
Servo myservo;

void setup()
{
  Serial.begin(9600);
  val = (analogRead(sensor_pin));
  Serial.println("working");
  myservo.attach(9);
}

void loop()
{
  Serial.println(val);   
  delay(100);      
    
}

so in the serial monitor i just get a constant reading of 523 regardless of whether the positive lead from the battery pack is touching the wire going to analog 5. Sometimes, at random, it will oscillate from 0 to 1023 but the readings still have no bearing on whether the connection has been made from the battery pack to the analog input. I got this to work perfectly a couple of weeks ago but then i plugged it in again and i haven’t gotten it to work since.

Code in setup() only runs once.
Move your val = (analogRead(sensor_pin)); to the loop() function

Also, place a 10K resistor from A5 to ground.