yt_link
insta_link
fb_link
twitter_link

7 segments display
page 1/1


7 segments display MAX7219 with Arduino

Help me by sharing this post



This is a very short example. How to use these kind of mudules with the MAX7219 drivers and control 8 seven segments displays. It uses serial communication so we only need 3 wires for data, clock and CS. We can supply this module at 5V and show numbers, a few letters and 7 decimal points.

First, you need a 7 segments display like this one on this link. This uses serial data to show up to 8 numbers from 0 to 9 and 7 decimal dots. To send data, all we ahve to do is to shift the bytes on the data pin.

7 segments MAX7219 Arduino example







PART 1 - Schematic


Ok, make the SPI connections as below between the LCD and te Arduino pins. Supply 5V and connect GND as well. To turn ON the backlight you ahve to connect GND to the light pin. Next, go below and downlaod the library and see the example code. Upload the code and test the LCD.


scheamtic Arduino MAX7219 7 segments




PART 2 - Example code


We don't need any library for this example. All we have to do is to send data to the chip by shifting each byte value on the data pin. To know what values we have to send to each register, check this datasheet of this module to know mopre. Then uplaod the test code, make the connections and give it a test.

Download the example code (simple):
Download the example code HELLO:



/*  7 segment display MAX7219 driver serial control
 Schematic: https://www.electronoobs.com/eng_arduino_tut54_sch1.php
 Code: https://www.electronoobs.com/eng_arduino_tut54_code1.php
*/

#define MAX7219_Data_IN 2
#define MAX7219_Chip_Select  3
#define MAX7219_Clock 4

byte adr = 0x08;
byte num = 0x00;
int i = 0;

void shift(byte send_to_address, byte send_this_data)
{
  digitalWrite(MAX7219_Chip_Select, LOW);
  shiftOut(MAX7219_Data_IN, MAX7219_Clock, MSBFIRST, send_to_address);
  shiftOut(MAX7219_Data_IN, MAX7219_Clock, MSBFIRST, send_this_data);
  digitalWrite(MAX7219_Chip_Select, HIGH);
}




void setup() {
  pinMode(MAX7219_Data_IN, OUTPUT);
  pinMode(MAX7219_Chip_Select, OUTPUT);
  pinMode(MAX7219_Clock, OUTPUT);
  digitalWrite(MAX7219_Clock, HIGH);
  delay(200);

  //Setup of MAX7219 chip
  shift(0x0f, 0x00); //display test register - test mode off
  shift(0x0c, 0x01); //shutdown register - normal operation
  shift(0x0b, 0x07); //scan limit register - display digits 0 thru 7
  shift(0x0a, 0x0f); //intensity register - max brightness
  shift(0x09, 0xff); //decode mode register - CodeB decode all digits

}

void loop() {
  
  //Data transfer
  shift(0x08, 0x00); //digit 7 (leftmost digit) data
  shift(0x07, 0x01);
  shift(0x06, 0x02);
  shift(0x05, 0x03);
  shift(0x04, 0x04);
  shift(0x03, 0x05);
  shift(0x02, 0x06);
  shift(0x01, 0x07); //digit 0 (rightmost digit) data
  delay(1000);
  shift(0x08, 0x07); //digit 7 (leftmost digit) data
  shift(0x07, 0x06);
  shift(0x06, 0x05);
  shift(0x05, 0x04);
  shift(0x04, 0x03);
  shift(0x03, 0x02);
  shift(0x02, 0x01);
  shift(0x01, 0x00); //digit 0 (rightmost digit) data
  delay(1000);
}








Next tutorial →
More tutorials ←

Help me by sharing this post








ADVERTISERS
PCBWAY PCB service



Gearbest Alfawise U30 2.8 inch Touch Screen DIY Desktop 3D Printer - U30 EU Plug Black
Alfawise U30 2.8 inch Touch Screen DIY Desktop 3D Printer - U30 EU Plug Black only $$162.89

AFFILATE

Gearbest Creality3D CR - 10S 3D Printer - EU Plug Upgrade Version Coffee and Black
Creality3D CR - 10S 3D Printer - EU Plug Upgrade Version Coffee and Black only $$352.94

Gearbest Creality 3D Ender-3 V-slot Prusa I3 DIY 3D Printer Kit 220 x 220 x 250mm Printing Size - EU Plug Black
Creality 3D Ender-3 V-slot Prusa I3 DIY 3D Printer Kit 220 x 220 x 250mm Printing Size - EU Plug Black only $$153.84

Gearbest Alfawise U20 Large Scale 2.8 inch Touch Screen DIY 3D Printer - EU - U20 EU Plug Black
Alfawise U20 Large Scale 2.8 inch Touch Screen DIY 3D Printer - EU - U20 EU Plug Black only $$253.39