Inductive sensor

An inductive sensor uses a magnetic field to detect metallic objects. The magnetic field is created by a coil that conducts an electric current. By putting a metallic object in the magnetic field, the magnetic field is influenced which can be detected by measuring the change in induction of the coil.

Inductive sensors need metal in the object you are trying to detect otherwise the magnetic field in the coil is not influenced. So detecting glass, ceramics, plastic, wood or smilar is not possible. On the other hand, the non conductive material is not influencing the sensor which makes it usable in moist and dusty situations.

Component information


Product Nr : LJ12A3-4-Z/BX


  • Measures the object at a distance of 4mm +10%
  • Input voltage : 6V - 36V
  • Output type : NPN, NO
  • Connection : 3 wire

Typical application for Arduino

The sensor is connected to the connector J1. The Arduino label is connectoed to an Arduino digital input pin.

R1 is a pull up resistor making sure that the signal is pulled up to 5V when the sensor is not detecting any metallic object. When sensor detects a metallic object, the output pin is pulled to ground.

R2 is added to limit the currect running from the sensor to the Arduino.

Arduino sample code

//Declare pin assignment
//Induction sensor uses pin 6 as input

void setup() {
  //Initialize serial port
  //Set input or output modes for the used ports.
  //LED_BUILTIN is a standard pin assignmet for Arduino for the LED on the board. It uses pin 13. This pin is set to output
  //The sensor pin is set to input as we need to read the value of the pin.
  //Let the user know setup is done through the serial port
  Serial.println("Setup done");

void loop() {
  //Input is low = active so we need to check if the port is equal to zero.
  if (digitalRead(INDSENSORPIN) == 0) {
    //The input is low so metal is detected
    //Let the user know we detected it through the serial port
    Serial.println("detection = 1");
    //Swith the LED on the Arduino board on
    digitalWrite(LED_BUILTIN, HIGH);
  } else {
    //Let the user know no cap is detected through the serial port
    Serial.println("detection = 0");
    //Switch the LED on the Arduino board off
    digitalWrite(LED_BUILTIN, LOW);