Capacitive sensor

NPN INDUCTIVE SENSOR

I will have to guess that the sensor has an open collector output. That means that in order for it to work it needs a pullup to Vcc. Since it is NPN I would also guess that it is not an analog output. Connect to a digital input (A1 can be digital) and enable the internal pullup with:

pinMode(A1, INPUT_PULLUP);

Then read the state of the sensor with:

boolean metalDetected = digitalRead(A1);

But you must take that advise with a large grain of salt as I know nothing about the sensor except NPN. Again, a data sheet would be most useful. If you don't have a data sheet you should find one or get a sensor that has a data sheet.