Stufin
Home Quick Cart Profile

LJ12A3-4-Z/BX NPN 24V Approach Sensor Inductive Proximity Switch

Buy Now

Pin Configuration

  • LJ12A3-4-Z/BX NPN 24V Approach Sensor Inductive Proximity Switch Pinout and Connection Guide
  • The LJ12A3-4-Z/BX is a high-precision inductive proximity switch designed for detecting the presence or absence of metal objects. This NPN-type sensor has four pins, which are explained below:
  • Pin 1: VCC (Power Supply)
  • Function: Provides power to the sensor
  • Voltage: 24V DC
  • Connection: Connect to a 24V DC power supply
  • Pin 2: GND (Ground)
  • Function: Ground reference point for the sensor
  • Connection: Connect to the ground of the power supply or a common ground point in the circuit
  • Pin 3: NO ( Normally Open)
  • Function: Output signal when a metal object is detected
  • Type: NPN (Negative-Positive-Negative) open collector output
  • Connection: Connect to a load or a microcontroller input through a pull-up resistor (typically 1k to 10k)
  • Pin 4: No Connection
  • Function: Not connected internally
  • Connection: Leave unconnected
  • Connection Structure:
  • 1. Connect Pin 1 (VCC) to a 24V DC power supply.
  • 2. Connect Pin 2 (GND) to the ground of the power supply or a common ground point in the circuit.
  • 3. Connect Pin 3 (NO) to a load or a microcontroller input through a pull-up resistor (R1).
  • For example, connect Pin 3 to a LED and a 1k resistor in series, and then connect the other end of the resistor to the positive terminal of the power supply.
  • Alternatively, connect Pin 3 to a microcontroller input pin through a 1k pull-up resistor.
  • 4. Leave Pin 4 unconnected.
  • Example Circuit:
  • | Pin | Connection |
  • | --- | --- |
  • | 1 (VCC) | 24V DC Power Supply |
  • | 2 (GND) | Ground of Power Supply or Common Ground |
  • | 3 (NO) | R1 (1k) LED 24V DC Power Supply (Positive Terminal) |
  • | 4 (NC) | No Connection |
  • Note:
  • Make sure to use a suitable power supply and follow proper safety precautions when working with electrical components.
  • The LJ12A3-4-Z/BX sensor has an internal oscillator and detection circuitry, which allows it to operate independently without the need for external components.
  • For more information on using this sensor with microcontrollers or other circuits, please refer to the datasheet or contact the manufacturer's technical support.

Code Examples

LJ12A3-4-Z/BX NPN 24V Approach Sensor Inductive Proximity Switch Documentation
Overview
The LJ12A3-4-Z/BX is a high-sensitivity, NPN-type inductive proximity switch designed for detecting the presence or absence of metallic objects. It operates on a 24V supply and offers a reliable and efficient sensing solution for a wide range of applications.
Pinout
| Pin | Description |
| --- | --- |
| VCC | Power supply (24V) |
| GND | Ground |
| OUT | Output signal (NPN Open Collector) |
Technical Specifications
Operating voltage: 24V DC
 Detection distance: 4mm
 Response time: 10ms
 Output type: NPN Open Collector
 Operating temperature: -25C to 70C
Code Examples
### Example 1: Basic Object Detection using Arduino
This example demonstrates how to use the LJ12A3-4-Z/BX proximity switch to detect the presence of a metallic object using an Arduino board.
```c
const int sensorPin = 2;  // Connect the sensor output to digital pin 2
const int ledPin = 13;    // Connect an LED to digital pin 13 (optional)
void setup() {
  pinMode(sensorPin, INPUT);
  pinMode(ledPin, OUTPUT);
}
void loop() {
  int sensorState = digitalRead(sensorPin);
  if (sensorState == LOW) {
    // Object detected, turn on the LED
    digitalWrite(ledPin, HIGH);
  } else {
    // No object detected, turn off the LED
    digitalWrite(ledPin, LOW);
  }
  delay(50);
}
```
### Example 2: Distance Measurement using Raspberry Pi (Python)
This example demonstrates how to use the LJ12A3-4-Z/BX proximity switch to measure the distance between the sensor and a metallic object using a Raspberry Pi and Python.
```python
import RPi.GPIO as GPIO
import time
# Set up GPIO mode
GPIO.setmode(GPIO.BCM)
# Define sensor pin and output pin
sensor_pin = 17
output_pin = 18
# Set up sensor pin as input and output pin as output
GPIO.setup(sensor_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(output_pin, GPIO.OUT)
try:
    while True:
        # Read sensor state
        sensor_state = GPIO.input(sensor_pin)
        
        if sensor_state == False:
            # Object detected, toggle output pin
            GPIO.output(output_pin, not GPIO.input(output_pin))
            print("Object detected!")
        else:
            print("No object detected.")
        
        time.sleep(0.1)
except KeyboardInterrupt:
    GPIO.cleanup()
```
Note: In both examples, make sure to connect the sensor output to a suitable input pin on your microcontroller or single-board computer, and ensure that the power supply and ground connections are made according to the datasheet.