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

10,429 views

Introduction

We are sure that you have heard the name “proximity sensor,” which finds widespread usage, particularly for security management. It is also used to identify parts in automated manufacturing lines and in industrial conveyor systems. There are numerous types of proximity sensors, each of which uniquely detects targets. Capacitive and inductive proximity sensors are the two kinds used most often nowadays. In this article, we are Interfacing Inductive Proximity Sensor LJ12A3-4-Z/BX with Arduino.

Inductive proximity sensors are non-contact sensors that can detect metal items. These sensors are used to detect the closeness of metal objects. An oscillator drives a coil when an object comes close to it, following the principle of induction.

What is a Proximity Sensor?

A proximity sensor is a type of sensor that does not need physical contact and can detect the existence of an object as soon as that object enters the sensor’s region of operation.

Proximity Sensor

Hardware Components

You will require the following hardware for Interfacing Inductive Proximity Sensor LJ12A3-4-Z/BX with Arduino.

S.noComponentValueQty
1.Arduino UNO1
2.Inductive ProximityLJ12A3-4-Z/BX1
3.Resistor10KΩ1
4.Battery9V1
5.9V Battery Clips with Bare Leads1
6.Breadboard1
7.Jumper Wires1

Inductive Proximity Sensor LJ12A3-4-Z/BX with Arduino

To build the circuit, you need to follow the given steps:

Schematic

Make connections according to the circuit diagram given below.

Inductive Proximity Sensor LJ12A3-4-ZBX Arduino Circuit

Wiring / Connections

ArduinoInductive ProximityBattery
VCCVCC
GNDGNDGND
A2Out

Installing Arduino IDE

First, you need to install Arduino IDE Software from its official website Arduino. Here is a simple step-by-step guide on “How to install Arduino IDE“.

Code

Now copy the following code and upload it to Arduino IDE Software.

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);
    }
}

Let’s Test It

Once you have completed making the connections and uploading the code, its now time to test the circuit!

Place a metal object in front of the sensor and observe its performance. On the serial monitor, you’ll be able to read the messages.

Working Explanation

Let’s dive into the code to understand the working of the circuit:

  • First, we define the Arduino pin connected to the sensor pin.
  • After that, in the void setup function, the pin is configured as an input using the pinMode() function. 
  • In the void loop() function, the code reads the digital value of the pin using digitalRead() and stores it in the variable sensorValue. If sensorValue is HIGH, the pin receives no input, and the message “no Object” is printed to the serial monitor. If sensorValue is LOW, it means that the pin is receiving input, and the message “Object Detected” is printed to the serial monitor. In both cases, the program waits for some milliseconds before looping again.

Applications

  • Object detection
  • Security and safety devices
  • Self-driving cars
  • Anti-aircraft systems
  • Assembly lines, etc

Conclusion.

We hope you have found this Inductive Proximity Sensor Circuit very useful. If you feel any difficulty making it feel free to ask anything in the comment section.