In-stock items handed to the courier within 24-48 hours · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy

© 2026 Geekobot. All rights reserved.

+91 91810 15606 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

Product directory · Sitemap

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,927 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,712 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,320 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,656 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,307 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers499 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries585 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors297 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs576 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays192 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping122 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test733 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics191 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits323 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts220 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio110 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Projects
  3. ›Proximity sensor RPM and counter

Sensor projects

Shaft RPM meter and part counter with an inductive proximity sensor

Count metal parts or bolt heads passing a 12 V inductive sensor, and turn the pulses into shaft RPM on a 4-digit display.

By Geekobot Learning Team

Intermediate
Difficulty
2 to 3 hours
Build time
₹1,544
Parts cost
11
Parts
Arduino
Platform
Add all parts · ₹1,544Start building
  • Workshop & industry
  • Measurement & tools
NANO12:30
Tap a part to see what it does
OverviewPartsWiringBuildCodeTroubleshootFAQIdeas

What you'll build

An inductive proximity sensor sees metal without touching it, a few millimetres from its face, and it keeps working in oil, dust and vibration. The common LJ12A3-4-Z/BX runs on 6 to 36 V and its NPN output pulls to 0 V while metal is in front. An optocoupler passes that signal to a 5 V Arduino Nano, which counts each pass and works out RPM from the time between pulses. Point it at one bolt head on a pulley for speed, or at parts on a chute for a count.

What you'll learn

  • How NPN and PNP sensor outputs differ
  • Isolating a 12-24 V signal with an optocoupler
  • Turning pulse timing into RPM with an interrupt
Safety

Keep fingers and loose wires away from turning shafts; mount the sensor with the machine stopped.

The 12 V side and the Nano side must only meet through the optocoupler.

  1. SenseInductive sensor sees each metal target
  2. ThinkNano counts pulses and times them
  3. ActTM1637 shows RPM or the count

Parts list

Tick anything you already have and the total updates.

PartQtyPrice
  • NANO
    Generic Nano CH340 Development Board (Soldered)
    GB-SBCD-0339Guide

    Counts the pulses and drives the display

    × 1₹185₹185
  • LJ12A3-4-Z/BX Inductive Proximity Sensor NPN NO DC6-36V 4mm Range
    GB-SENS-1203Guide

    LJ12A3-4-Z/BX inductive sensor: NPN, normally open, 6-36 V, 4 mm range on steel

    × 1₹198₹198
  • Optocoupler IC (Transistor, Triac and High-Speed Output)
    GB-SEMI-0108

    PC817-type optocoupler between the 12 V sensor and the 5 V Nano

    × 1₹4₹4
  • 12:30
    TM1637 4-Digit 7-Segment Display Module
    GB-DISP-0011Guide

    4-digit display for RPM or the count

    × 1₹55₹55
  • Tactile Push Button Switch
    GB-SWRL-0007Guide

    Push button: switch between RPM and count, hold to reset

    × 1₹7₹7
  • Resistor Assortment Kit (30 Values)
    GB-PASV-0002Guide

    1k for the optocoupler LED

    × 1₹33₹33
  • LJ18A3-8-Z/BX Inductive Proximity Sensor NPN NO, DC 6–36V, 8mm Range, IP54
    GB-SENS-1270Guide

    LJ18A3-8-Z/BX M18 sensor with 8 mm range, for targets that wobble

    × 1₹389₹389
  • LJC30A3-H-Z/BX Capacitive Proximity Sensor NPN NO, DC 6–36V, 300mA, Detection Range 1–15 mm
    GB-SENS-1232Guide

    Capacitive proximity sensor: also sees plastic, grain or liquid through a tank wall

    × 1₹529₹529
  • PC817 4-Channel Optocoupler Isolation Module
    GB-SWRL-0088

    Ready PC817 optocoupler board, if you prefer screw terminals to a bare chip

    × 1₹77₹77
  • Solderless Breadboard
    GB-PROT-0001Guide

    Holds the parts without soldering

    × 1₹18₹18
  • Dupont Jumper Wires (40 pcs)
    GB-WIRE-0001Guide

    Connects the parts

    × 1₹49₹49

Complete kit

11 of 11 parts in one tap

₹1,544

GST included

3% off these parts while the whole kit stays in your cart

Parts you still need

₹1,544

11 of 11 parts. Tick anything you already have.

About ₹46,320 before bulk pricing for 30 kits.

Request bulk quote

Tools you'll need

  • Digital Multimeter

Learn the parts

  • ESP32 vs Arduino Uno
  • LJ12A3-4-Z/BX Inductive Proximity Sensor
  • TM1637 4-digit display
  • Pull-Up and Pull-Down Resistors
  • I2C Explained
  • Industrial Inductive and Capacitive Proximity Sensors
  • Arduino Uno

Calculators for this build

  • Ohm’s law calculator
  • Resistor color code calculator (colour code)
  • Resistor power rating calculator

Wiring

Follow the colours: red is power, dark grey is ground, blue is a signal.

The sensor needs 6 to 36 V; a 12 V adapter is fine (sold separately). The Nano runs from USB or 5 V. Keep the 12 V ground separate from the Nano: the optocoupler is the only link between them.

PartPinConnect toNote
Proximity sensorBrown / Blue12 V + / 12 V −Check the colours on your sensor's label
Proximity sensorBlack (NPN output)Optocoupler pin 2 (cathode)Opto pin 1 (anode) to 12 V + through the 1k resistor
OptocouplerPin 4 collector / pin 3 emitterD2 / Nano GNDD2 uses INPUT_PULLUP
TM1637CLK / DIO / VCC / GNDD5 / D6 / 5V / GND
Push buttonOne leg / other legD4 / GND
  • Proximity sensorBrown / Blue → 12 V + / 12 V −Check the colours on your sensor's label
  • Proximity sensorBlack (NPN output) → Optocoupler pin 2 (cathode)Opto pin 1 (anode) to 12 V + through the 1k resistor
  • OptocouplerPin 4 collector / pin 3 emitter → D2 / Nano GNDD2 uses INPUT_PULLUP
  • TM1637CLK / DIO / VCC / GND → D5 / D6 / 5V / GND
  • Push buttonOne leg / other leg → D4 / GND
Built it? Check your wiring before you power up.Pick the pin each wire went to and we'll point out swapped pins, power mistakes and pins that clash.

Step-by-step build

0 of 6 done

Code

prox_rpm_counter.inoVerify & upload in Electrolark
#include <TM1637Display.h>
TM1637Display disp(5, 6);
const int SENSOR = 2, BUTTON = 4;
const int TARGETS_PER_TURN = 1;      // bolt heads or teeth the sensor sees per revolution

volatile unsigned long pulses = 0, lastPulseUs = 0, periodUs = 0;
void onPulse() {
  unsigned long now = micros();
  if (now - lastPulseUs < 2000) return;   // ignore bounces shorter than 2 ms
  periodUs = now - lastPulseUs;
  lastPulseUs = now;
  pulses++;
}

bool showRpm = false;

void setup() {
  pinMode(SENSOR, INPUT_PULLUP);
  pinMode(BUTTON, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(SENSOR), onPulse, FALLING);  // LOW while metal is in front
  disp.setBrightness(5);
  Serial.begin(115200);
}

void loop() {
  if (digitalRead(BUTTON) == LOW) {
    unsigned long t = millis();
    while (digitalRead(BUTTON) == LOW) ;
    if (millis() - t > 1500) { noInterrupts(); pulses = 0; interrupts(); }  // long press: reset
    else showRpm = !showRpm;                                                // short press: switch view
  }

  noInterrupts();
  unsigned long n = pulses, p = periodUs, last = lastPulseUs;
  interrupts();

  float rpm = 0;
  if (p > 0 && micros() - last < 3000000UL) rpm = 60000000.0 / (p * (float)TARGETS_PER_TURN);

  disp.showNumberDec(showRpm ? (int)rpm : (int)(n % 10000));
  Serial.print("count "); Serial.print(n); Serial.print("  rpm "); Serial.println(rpm, 0);
  delay(200);
}

Troubleshooting

Count never changes+

Check the sensor LED lights when metal is near. If it does, swap the optocoupler pins 1 and 2: the LED inside only works one way round.

Counts two for one target+

The target is at the edge of the sensing range and flickers. Move the sensor 1 mm closer, or raise the 2 ms bounce filter in the sketch.

RPM jumps around at low speed+

With one target the reading updates once a turn. Add more evenly spaced bolts and set TARGETS_PER_TURN to match.

FAQ

Will it see aluminium or brass?+

Yes, but at a shorter distance: roughly half the steel range for aluminium. Check the correction factors in the sensor's datasheet.

Can I skip the optocoupler?+

Not safely. Many NPN sensors pull their output up to the supply voltage inside, so 12 V could reach the Nano pin.

Does it work with a 24 V PLC supply?+

Yes. With 24 V use a 2.2k resistor for the optocoupler LED instead of 1k.

What is the difference between NO and NC?+

A normally open (NO) sensor switches on when metal arrives; a normally closed (NC) one switches off. The sketch counts the change either way if you swap FALLING for RISING.

What parts do I need to build the shaft RPM meter and part counter with an inductive proximity sensor?+

11 parts: Generic Nano CH340 Development Board (Soldered), LJ12A3-4-Z/BX Inductive Proximity Sensor NPN NO DC6-36V 4mm Range, Optocoupler IC (Transistor, Triac and High-Speed Output), TM1637 4-Digit 7-Segment Display Module, Tactile Push Button Switch, Resistor Assortment Kit (30 Values), LJ18A3-8-Z/BX Inductive Proximity Sensor NPN NO, DC 6–36V, 8mm Range, IP54, LJC30A3-H-Z/BX Capacitive Proximity Sensor NPN NO, DC 6–36V, 300mA, Detection Range 1–15 mm, PC817 4-Channel Optocoupler Isolation Module, Solderless Breadboard, plus 1 more. Tools: Digital Multimeter. On this page you can tick the parts you already have and add only the rest to your cart.

How hard is it and how long does it take?+

It is a intermediate project and takes about 2 to 3 hours. The build on this page has 6 steps.

Do I need to write the code myself?+

No. This page has the complete, tested code (prox_rpm_counter.ino).

How much does the shaft RPM meter and part counter with an inductive proximity sensor cost to build?+

About ₹1,544 for the parts at the prices on this page, plus tools if you do not have them. Quantity price breaks lower the cost when you build several.

What will I learn from this project?+

How NPN and PNP sensor outputs differ; Isolating a 12-24 V signal with an optocoupler; Turning pulse timing into RPM with an interrupt.

Is it safe to build?+

Keep fingers and loose wires away from turning shafts; mount the sensor with the machine stopped. The 12 V side and the Nano side must only meet through the optocoupler.

What can I build next with these parts?+

Ideas that reuse this build: Conveyor box counter. They are listed under Take it further on this page.

Take it further

  • Conveyor box counter

Related projects

  • UNO
    Sensor
    Beginner· 1 hour

    LPG gas leak alarm

    A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.

    ₹505 · 8 partsArduino
  • NANO
    Sensor
    Beginner· 1–2 hours

    Smoke alarm with OLED readout

    See the smoke level live on a crisp screen and get a loud warning when it spikes.

    ₹539 · 6 partsArduino
  • UNO
    Sensor
    Beginner· 45 minutes

    Flame detector fire alarm

    An infrared eye that spots an open flame and raises the alarm.

    ₹434 · 8 partsArduino
  • UNO
    Sensor
    Beginner· 1 hour

    PIR intruder alarm

    Walk into the room and it sounds the alarm: the classic first security build.

    ₹459 · 8 partsArduino

Learning project. Check every circuit and the datasheet of each part before you power it up.

Ask the Community

Ask a question Share your build