Inductive Proximity Sensor Interface with Arduino

The proximity sensor is used to detect the presence of nearby objects. For example, the LJ12A3-4-Z/BX inductive proximity sensor is a compact, low-power, user-friendly, and stable proximity switch sensor used to detect the presence of metal objects.

Inductive Proximity Sensor Interface with Arduino

The LJ12A3-4-Z/BX has three pins, two for connecting to a 6-36V power supply, and the third is a digital output pin, which outputs PNP, NO (normally open state), meaning it is usually in a LOW state and only switches to HIGH when an object is detected, with a detection distance of 4mm, detecting objects limited to copper, aluminum, iron, etc.

Since the supply voltage exceeds 5V, this sensor cannot be powered by Arduino and must be powered by an external battery. The project BOM is as follows:

Arduino UNO R3 ×1

LJ12A3-4-Z/BX Inductive Proximity Sensor ×1

10K resistor ×2

9V battery ×1

9V battery clip ×1

Male-Male jumper wire ×1

Breadboard ×1

Arduino IDE

First, use a voltage divider circuit to reduce the input voltage from 9V to 4.5V, and then connect the middle point of the voltage divider circuit to the input pin of the Arduino.

Inductive Proximity Sensor Interface with Arduino

Then upload the following code to the Arduino:

const int Pin=2;
void setup() {   pinMode(Pin, INPUT);   Serial.begin(9600);}
void loop() {   int sensorValue = digitalRead(Pin);   if(sensorValue==HIGH){       Serial.println("no Object");       delay(500);   }   else{       Serial.println("Object Detected");       delay(500);   }}

After uploading the code, the sensor begins to read values. If the output is LOW, it indicates that no object is present nearby; if the output is HIGH, it indicates that an object has been detected, with a detection interval of 0.5 seconds.

If a metal object is waved in front of the sensor three times, the results are as follows:

Inductive Proximity Sensor Interface with Arduino

Inductive Proximity Sensor Interface with Arduino
(
END
)
More exciting content, stay tuned to EET Video Account

Leave a Comment

×