Contents

Interfacing Inductive Proximity Sensor LJ12A3-4-Z/BY with Arduino

Inductive Proximity Sensor LJ12A3-4-Z/BY Features

A proximity sensor is a sensor able to detect the presence of nearby objects. The inductive proximity sensor LJ12A3-4-Z / BY has three pins, two of which are connected to a supply voltage of 6 to 36V. The output pin is PNP and NO (Normally Open). That is, it is normally Low and when it detects an object, it is HIGH. The detection distance is 4 mm and it can only detect metal objects such as copper, aluminum, iron, etc.

Note

Because the operation voltage is more than 5V, it can’t be powered by Arduino. So, we can use a battery to power it up.

Warning

Since the output voltage is more than 5 volts, we use voltage divider to connect the sensor output to Arduino.

Inductive Proximity Sensor LJ12A3-4-Z/BY Pinout

This Module has 3 wires:

  • VCC: Module power supply – 6-36V (Brown)
  • GND: Ground (Blue)
  • OUT: Digital output (Black)

You can see the pinout of this module in the image below.

Required Materials

Hardware Components

Arduino UNO R3 × 1
Inductive Proximity Sensor LJ12A3-4-Z/BY 3-Wire × 1
10K resistor × 2
9V Battery × 1
9V Battery Clips with Bare Leads × 1
Male to Male Jumper wire × 1
400 Tie point Breadboard × 1

Software Apps

Arduino IDE

Interfacing Inductive Proximity Sensor LJ12A3-4-Z/BY with Arduino

Step 1: Circuit

Reduce the Arduino input voltage (sensor output voltage) from 9V to 4.5V as shown below through the resistance circuit. Then connect the middle end of the resistor circuit to the Arduino input.

Step 2: Code

Upload the following code to your Arduino.

 /*
  LJ12A3-4-ZBY-Inductive-Proximity-Sensor
  made on 04 Nov 2020
  by Amir Mohammad Shojaee @ Electropeak
  
Home
*/ const int Pin=2; void setup() { pinMode(Pin, INPUT); Serial.begin(9600); } void loop() { int sensorValue = digitalRead(Pin); if(sensorValue==LOW){ Serial.println("no Object"); delay(500); } else{ Serial.println("Object Detected"); delay(500); } }

We read the sensor output every half second. If it is LOW, no object is near the sensor and if it is LOW, it detects the object.

The Serial output is as follows. We put a metal object in front of the sensor three times to measure its performance

Liked What You See?​
Get Updates And Learn From The Best​

Leave a Reply

Your email address will not be published. Required fields are marked *