Arduino and MAX7219, 8 Digit, 7 Segment BCD Counter


Introduction: Arduino and MAX7219, 8 Digit, 7 Segment BCD Counter

In Embedded system design, seven segment displays are playing a major role as numerical visual indications. Seven segment LED displays are brighter, more attractive and provide a far viewing distance as well as a wider viewing angle as compared to LCD displays. Its available wide dimensions (0.3 inch to 6 inch) and different colors (RED, GREEN, BLUE, ORANGE, WHITE). It can display digits from 0 to 9 and quite a few characters like A, b, C, d, E, e, F, n, o, P, t, u, etc. This intractable is about interfacing 8 digits of 7 segment display by using popular MAX7219 display driver with Arduino Uno.

Parts and components

  • Arduino Uno board
  • Max7219 4 Digit 7Segment Common cathode displays = 2 Nos
  • Or Max7219 assembled board

Step 1: Schematic

  • The MAX7219 display driver chip provides a 3-wire serial (SPI) interface to drive 7-segment LED displays (common-cathode type) up to 8 digits.
  • The on-chip includes a BCD decoder, multiplex scan circuitry, segment and digit drivers, and an 8×8 static RAM to store the digit values.
  • The DIN, LOAD and CLOCK pins of MAX7219 is connected with 4,3 and 2 digital IO pins of Arduino.
  • Two (RED and BLUE) 4 digit, common cathode seven segment displays are connected to the drive pins on MAX7219.
  • Otherwise, one can use the pre-assembled MAX7219 board with 8 digits, and connect the drive pins accordingly.

Step 2: Software

  • The Arduino LedControl library is used for displaying digits on MAX7219.
  • The count variable updated by one count, at every 500mS.
  • The count_one variable which is duplicate of count, will be converted into BCD, and displayed at the 4,5,6 and 7th digits.
  • The count_two variable which is multiplication 7 of count, will be converted into BCD, and displayed at the 1,2,3 and 4th digits.
  • The count will be reset to zero once it reaches 9999.


  • The project is successfully simulated by using the Proteus.
  • The MAX7219 can be used for many embedded projects as numerical display.


Demonstrates the use of MAX7219 and 2 of 4x7 Segment display.

The Arduino circuit connection for 7219:

* MAX7219 DIN pin to digital pin 4

* MAX7219 LOAD pin to digital pin 3

* MAX7219 CLOCK pin to digital pin 2


Name:- M.Pugazhendi

Date:- 05thJul2016

Version:- V0.1




// inputs: DIN pin, CLK pin, LOAD pin. number of chips

LedControl mydisplay = LedControl(4, 2, 3, 1);

unsigned int count = 0;

unsigned int count_one = 0;

unsigned int count_two = 0;

void setup()


mydisplay.shutdown(0, false); // turns on display

mydisplay.setIntensity(0, 15); // 15 = brightest

mydisplay.setDigit(0, 0, 9, false);

mydisplay.setDigit(0, 1, 8, false);

mydisplay.setDigit(0, 2, 7, false);

mydisplay.setDigit(0, 3, 6, false);

mydisplay.setDigit(0, 4, 5, true);

mydisplay.setDigit(0, 5, 4, false);

mydisplay.setDigit(0, 6, 3, false);

mydisplay.setDigit(0, 7, 2, false);


void loop()



if((count*7) >= 9999)


count = 0;


count_one = HexToBCD(count);

count_two = HexToBCD(count*7);

mydisplay.setDigit(0, 0, ((count_two>>12)&0x0F), false);

mydisplay.setDigit(0, 1, ((count_two>>8)&0x0F), false);

mydisplay.setDigit(0, 2, ((count_two>>4)&0x0F), false);

mydisplay.setDigit(0, 3, ((count_two>>0)&0x0F), false);

mydisplay.setDigit(0, 4, ((count_one>>12)&0x0F), false);

mydisplay.setDigit(0, 5, ((count_one>>8)&0x0F), false);

mydisplay.setDigit(0, 6, ((count_one>>4)&0x0F), false);

mydisplay.setDigit(0, 7, (count_one&0x0F), false);





* \brief Coverts hex into BCD


* This function will coverts hex into BCD


* \param[in] byte

* \param[out] byte

* \return Nill




unsigned int HexToBCD(unsigned int number)


unsigned char i=0;

unsigned int k = 0;



k = ( k ) | ((number%10) << i*4);

number = number / 10;







    • Woodworking Contest

      Woodworking Contest
    • Make it Move Contest

      Make it Move Contest
    • Planter Challenge

      Planter Challenge

    We have a be nice policy.
    Please be positive and constructive.




    when I include <LedControl.h>

    I get error messages:

    Arduino: 1.8.4 (Windows 10), Board: "Arduino/Genuino Uno"
    C:\Users\mdoti\Documents\Arduino\MAX7219_8digit_7segment_BCD_Counter\MAX7219_8digit_7segment_BCD_Counter.ino: In function 'void loop()':
    MAX7219_8digit_7segment_BCD_Counter:44: error: 'x0F' was not declared in this scope
    mydisplay.setDigit(0, 0, ((count_two>>12)&x0F), false);
    exit status 1
    'x0F' was not declared in this scope

    #include what?



    // inputs: DIN pin, CLK pin, LOAD pin. number of