Capacitive sensor

Hi guys, I need help. I need to test my Capacitive sensor if its working, Please give me a program code to test my sensor. Thanks :smiley:

Look here.

Thanks, it was a big help. It worked. But for now, we have to find a program or even a guide to test our INDUCTIVE SENSOR. thanks in advance!

If you want help with the inductive sensor, please provide a data sheet or link to the sensor. There are different types with different outputs and we need to know what we are dealing with to minimize guesswork.

groundFungus:
If you want help with the inductive sensor, please provide a data sheet or link to the sensor. There are different types with different outputs and we need to know what we are dealing with to minimize guesswork.

float metalDetected;
int monitoring;
int metalDetection = 1;

void setup(){
Serial.begin(9600);
}

void loop(){
monitoring = analogRead(metalDetection);
metalDetected = (float) monitoring*100/1024.0;
Serial.print(“14CORE METAL DETECTOR TEST”);
delay(500);
Serial.print(“Initializing Proximity Sensor”);
delay(500);
Serial.print(“Please wait…”);
delay(1000);
Serial.print(“Metal is Proximited = “);
Serial.print(metalDetected);
Serial.println(”%”);
if (monitoring > 250)
{Serial.println(“Metal is Detected”);
delay(1000);Serial.println("%");}
else (monitoring < 250)
{Serial.println(“Metal not is Detected”);
delay(1000);}

}

HERE IS tHE CODE WE ARE TRYING TO USE, we have NPN INDUCTIVE 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.