Introduction
In this tutorial, we will learn about the LJ12A3-4-Z/BX sensor, what is an inductive proximity sensor and we will build a simple project using the LJ12A3-4-Z/BX sensor and an Arduino.
Inductive Proximity NPN Sensor LJ12A3-4/BX
The LJ12A3-4-Z/BX Module will be our main component for this tutorial. This module has a stainless steel threaded body with 3 wires for connection. Figure 1 shows the module as seen in fritzing.
Pin Out
The LJ12A3-4-Z/BX module has three wires.
Wire Colour | Description |
---|---|
Brown | +5V |
Black | Output |
Blue | GND |
What is an Inductive Proximity Sensor?
An inductive proximity sensor uses current-induced magnetic fields to detect nearby metal objects.
Project - Arduino Metal Detector
Our project will use the LJ12A3-4-Z/BX sensor and turn on a relay when it detects a metal object nearby.
Componentns
For this project, we need the following components:
- Arduino Uno board (1 pc.)
- LJ12A3-4-Z/BX Inductive Proximity NPN Sensor (1 pc.)
Wiring Diagram
The LJ12A3-4-Z/BX module pins are connected to the Arduino Uno board as follows:
Component Pin | UNO Board Pin |
---|---|
Brown | +5V |
Black | A0 |
Blue | GND |
Code
Below is the Arduino sketch for our project. I have added comments to explain important parts of the code. Save the code proximity_sensor.ino and upload it to your Arduino board.
// Arduino and proximity sensor
void setup ()
{
Serial.begin(9600); // initialize serial
}
void loop ()
{
Serial.print("Analog pin: "); // display analog values to serial
Serial.print(analogRead(A0));
}
Project Test
Apply power to your Arduino Uno board and open the Serial Monitor in the Arduino IDE. Arduino will read the input from the inductive proximity sensor and display the value in the serial monitor. A value greater than 250 means metal is detected.
SHOP THIS PROJECT
-
Arduino UNO CH340 MEGA328P Development Board with USB Cable – Compatible
$23.95Original price was: $23.95.$22.95Current price is: $22.95. Add to cart -