Raspberry Pi Pico – MAX7219 8x8 Dot Matrix Scrolling Display
by PugazhM in Circuits > Raspberry Pi
15867 Views, 12 Favorites, 0 Comments
Raspberry Pi Pico – MAX7219 8x8 Dot Matrix Scrolling Display
This instruct able is about interfacing 8x8 dot matrix display by using popular MAX7219 display driver with Raspberry Pi Pico, and it can be programmed using Python, for scrolling text display
Visit the following you tube channel for further information and videos.
https://www.youtube.com/channel/UCY4mekPLfeFinbQHp...
Matrix Scrolling Display Video Link
Abstract
The Raspberry Pi Pico is a tiny, fast, and versatile board built using RP2040 features a dual-core Arm Cortex-M0+ processor with 264KB internal RAM and support for up to 16MB of off-chip Flash. It provides wide range of flexible I/O options includes I2C, SPI, and uniquely Programmable I/O (GPIO) pins.
In Embedded system design, dot matrix displays are playing a major role for displaying Numerical, Alphanumerical, Scrolling, Blinking, Sign board or Pattern generated display indications. 8x8 dot matrix displays are brighter, more attractive and provide a far viewing distance as well as a wider viewing angle as compared to LCD displays. It can be stackable and available in wide dimensions (0.3 inch to 6 inch) and different colors (RED, GREEN, BLUE, ORANGE, WHITE). This instruct able is about interfacing 8x8 dot matrix display by using popular MAX7219 display driver with Raspberry Pi Pico, and it can be programmed using Python, for scrolling text display.
Reference
"Get started with MicroPython on Raspberry Pi Pico” by Gareth Halfacree and Ben Everard
Raspberry Pi Pico, Blink on board LED, Instructables / Youtube
MicroPython max7219 case cascdable 8x8 LED matrix driver
Components
Raspberry Pi Pico = 1 No
Micro USB Cable
Max7219 Single Dot Matrix Display Module
Or Max7219 4x1 Dot Matrix Display Module
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 MAX7219 on-chip includes a BCD decoder, multiplex scan circuitry, segment and digit drivers, and an 8×8 static RAM for storing 64 of LEDs values.
The DIN, CLOCK and CS pins of MAX7219 is connected with GPIO3, GPIO2 and GPIO5 pins of Raspberry Pi Pico.
The 8x8 LED matrix module has 64 individual LEDs and it can be used for visual display applications (Scrolling, Blinking, Sign board or Pattern displays).
The 8x8 LED matrix module has 16 pins (8 row pins, and 8 column pins). Anode and Cathode of the LEDs are inter connected to row and column pins.
A pre-assembled “4 in 1 MAX7219 Dot Matrix Module, which as four MAX7219 connected in daisy chain format, is used for executing the experimentation. Each MAX7219 can handle one 8x8 matrix display.
The MAX7219 module is powered with +5VDC (VBUS) and GND.
MAX7219, 8x8 LED Matrix Display Library
It is a MicroPython max7219 cascadable 8x8 LED matrix driver.
Download the lib max7219.py driver library.
Open the RPi Pico as drive, and then copy the library into root directory. T
he library provides following functionalities
-- Initializing the device
-- Set intensity of the device
-- fill, text, scroll functionalities
Send the frame buffer to MAX7219 device for further processing
"""
MicroPython max7219 cascadable 8x8 LED matrix driver https://github.com/mcauser/micropython-max7219
MIT License Copyright (c) 2017 Mike Causer
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from micropython import const import framebuf
_NOOP = const(0) _DIGIT0 = const(1) _DECODEMODE = const(9) _INTENSITY = const(10) _SCANLIMIT = const(11) _SHUTDOWN = const(12) _DISPLAYTEST = const(15)
class Matrix8x8: def __init__(self, spi, cs, num): """ Driver for cascading MAX7219 8x8 LED matrices.
>>> import max7219 >>> from machine import Pin, SPI >>> spi = SPI(1) >>> display = max7219.Matrix8x8(spi, Pin('X5'), 4) >>> display.text('1234',0,0,1) >>> display.show()
""" self.spi = spi self.cs = cs self.cs.init(cs.OUT, True) self.buffer = bytearray(8 * num) self.num = num fb = framebuf.FrameBuffer(self.buffer, 8 * num, 8, framebuf.MONO_HLSB) self.framebuf = fb # Provide methods for accessing FrameBuffer graphics primitives. This is a workround # because inheritance from a native class is currently unsupported. # http://docs.micropython.org/en/latest/pyboard/library/framebuf.html self.fill = fb.fill # (col) self.pixel = fb.pixel # (x, y[, c]) self.hline = fb.hline # (x, y, w, col) self.vline = fb.vline # (x, y, h, col) self.line = fb.line # (x1, y1, x2, y2, col) self.rect = fb.rect # (x, y, w, h, col) self.fill_rect = fb.fill_rect # (x, y, w, h, col) self.text = fb.text # (string, x, y, col=1) self.scroll = fb.scroll # (dx, dy) self.blit = fb.blit # (fbuf, x, y[, key]) self.init()
def _write(self, command, data): self.cs(0) for m in range(self.num): self.spi.write(bytearray([command, data])) self.cs(1)
def init(self): for command, data in ( (_SHUTDOWN, 0), (_DISPLAYTEST, 0), (_SCANLIMIT, 7), (_DECODEMODE, 0), (_SHUTDOWN, 1), ): self._write(command, data)
def brightness(self, value): if not 0 <= value <= 15: raise ValueError("Brightness out of range") self._write(_INTENSITY, value)
def show(self): for y in range(8): self.cs(0) for m in range(self.num): self.spi.write(bytearray([_DIGIT0 + y, self.buffer[(y * self.num) + m]])) self.cs(1)
Downloads
Scrolling Display
The Raspberry Pi Pico “max7219.py” library is used for displaying text on 8x8 LED dot matrix.
The scrolling_message is initialized with “RASPBERRY PI PICO AND MAX7219 -- 8x8 DOT MATRIX SCROLLING DISPLAY”.
Find out the message length, and number of columns.
Scrolling speed is set into 50mS.
Frame buffer is scrolled at the rate of scrolling speed, and displays the running text on LED matrix.
'''
Demonstrates the use of MAX7219, Scrolling display. * Demonstrate to display the scrolling display. * Four numbers of the MAX7219 are connected in daisy chain. * 8x8 dot matrix module, (64 LEDs) is connected with each MAX7219 * totally 8x8x4 = 256 LEDs forming with 8 rows of 32 columns Display area. * The Raspberry Pi Pico pin connections are MAX7219 given below:
* MAX7219 VCC pin to VBUS * MAX7219 GND pin to GND * MAX7219 DIN pin to digital GPIO3 * MAX7219 CS pin to digital GPIO5 * MAX7219 CLOCK pin to digital GPIO2
Name:- M.Pugazhendi Date:- 10thJul2021 Version:- V0.1 e-mail:- muthuswamy.pugazhendi@gmail.com '''
# Import MicroPython libraries of PIN and SPI from machine import Pin, SPI
# Import MicoPython max7219 library import max7219
# Import time import time
#Intialize the SPI spi = SPI(0, baudrate=10000000, polarity=1, phase=0, sck=Pin(2), mosi=Pin(3)) ss = Pin(5, Pin.OUT)
# Create matrix display instant, which has four MAX7219 devices. display = max7219.Matrix8x8(spi, ss, 4)
#Set the display brightness. Value is 1 to 15. display.brightness(10)
#Define the scrolling message scrolling_message = "RASPBERRY PI PICO AND MAX7219 -- 8x8 DOT MATRIX SCROLLING DISPLAY"
#Get the message length length = len(scrolling_message)
#Calculate number of columns of the message column = (length * 8)
#Clear the display. display.fill(0) display.show()
#sleep for one one seconds time.sleep(1)
# Unconditionally execute the loop while True: for x in range(32, -column, -1): #Clear the display display.fill(0)
# Write the scrolling text in to frame buffer display.text(scrolling_message ,x,0,1) #Show the display display.show() #Set the Scrolling speed. Here it is 50mS. time.sleep(0.05)
Downloads
Conclusion
The project is successfully completed with Raspberry Pi Pico and 4x1 MAX7219, 8x8 dot matrix display module.
The MAX7219 can be used for many embedded projects as Numerical, Alphanumerical, Scrolling, Blinking, Sign board or Pattern generated display
Video Links
ScrollingDisplay.mp4
Visit the following you tube channel for further information and videos.
https://www.youtube.com/channel/UCY4mekPLfeFinbQHp...
If you enjoyed this instruct-able, then make sure you subscribe
Matrix Scrolling Display Video Link