Digital Pulse Counter

Recently I came to understand the true demand for a multi-purpose digital pulse counter. So I designed an east-to-build digital pulse counter circuit based on some generally available cheap electronic components. The quick microcontroller based design comprises of the following:

  • Digispark Attiny85 Development Board (original/clone)
  • TM1637 4-Digit Red LED Display (Catalex)
  • Mini Reed Switch Module (SKU-Mod 5 from ProtoSupplies)
  • & 9V 6F22 Alkaline Battery

As you might noticed, the Digispark Attiny85 development board is a little microcontroller module for hobby projects (, and the TM1637 LED display holds a special driver chip TM1637 by Titan Micro Electronics ( that requires only a two–wire bus interface (CLK & DIO) for communication with the microcontroller. The Mini Reed Switch module activates a switch closure when a magnetic field comes near to it. You can use a small neodymium magnet to create the requisite magnetic filed. You can consider the module (with a built-in 10K pull-up resistor) as an SPST switch with N/O (Normally Open) contacts (suitable for switching logic levels) until a magnet comes into close proximity to the glass envelope of the reed sensor. Output of the module is HIGH when the switch is open and is LOW when the switch contacts are closed. Here’s the hardware setup diagram:

Digital Pulse Counter-Hardware Setup Diagram
Hardware Setup Diagram

As usual, the code in in the style of the popular Arduino sketch and it’s very simple and easy to understand. However, note that here a special library (TM1637Display.h) is used to make things uncomplicated, and the downloaded library can be installed as any other Arduino library, by copying relevant files into a directory on the library search path of the Arduino IDE.

/* Digital Pulse Counter (v1)
 * Hardware: Digispark Dev.Board,TM1637 LED Display,& Mini Reed Switch Module
 * Arduino IDE Version: 1.6.9
 * Authored By T.K.Hareendran 
 * Publisher: Codrey Electronics 
 * Site:

#include <Arduino.h>
#include <TM1637Display.h> //Library for TM1637

#define CLK 2 // Display Clock PB2 
#define DIO 3 // Display Data I/O PB3

#define TEST_DELAY   2000 // Delay

TM1637Display display(CLK, DIO); //Display Setup

void setup()
  pinMode(0,INPUT); // Counter Trigger I/P PB0
  display.setBrightness(6); // Display Brightness

int numb=0;
int ctgr=0; 
void loop()
   display.showNumberDec(numb,false); // Function to display numbers upto 9999
   if(digitalRead(0)==0) // Read Counter Trigger I/P

After construction, countercheck everything and power up your digital pulse counter. After an initial delay of around 5 seconds you can see digit zero (0) at the rightmost of the display. The pulses are ready now to be counted after they get out from the mini reed switch module. The pulse counter counts the number of low-level inputs it receives and displays on the panel. Remember, the purpose of this Pulse counter is to count the number of pulses during a specified amount of time. Virtually there is zero limit to what you can do with this digital pulse counter – just replace the reed switch module with any other (compatible) sensor module (a fork-coupler, for example) to broaden the road!

Arduino-Digital Pulse Counter
(Pulse Counter – from author’s workbench)


  1. You have REALLY got my attention here, T.K. HAREENDRAN !
    I have just bought an up/dn presettable counter from china, which toggles a relay when a preset no. Is decremented to zero.. the basic need, but u cant see the preset number once set.. it just shows all red (seven segment led) zeros, leaving u to wonder if u put in the right number.
    Also, It wont decrement faster than 150Hz, and presetting the number is painful.

    Its supposed to count up to that no. But doesnt properly, counting up to the preset doesnt operate a relay & wont count up from zero with no preset.
    Its the only 1 on ebay i could find.
    Soooo, HELP! Am willing to pay 4 your time.

  2. Hi TK H. Re pulse counter,
    Any chance i could get a response soon.. or at least email so that i know u read my input
    Ray H.

Leave a Reply

Your email address will not be published. Required fields are marked *