Dot Matrix large screen speech sensor--max7219 dot matrix

Source: Internet
Author: User

MAX7219 lattice module can be used with three data lines to achieve 8*8 led lattice control, and do not need to participate in the scanning of single-chip computer, the use is very convenient. More importantly, it supports the use of modular cascade, without increasing the number of IO, the implementation of multi-module control. Therefore, in the large-screen meter, the use of 3 MAX7219 lattice modules into a 8*24 lattice screen.

The use of dot matrix encountered a little trouble, is about cascading use, the network query to the code of each piece of lattice write need to use a separate function, such as:

Write the data to the second piece of MAX7219
void Max7219_write_1 (Uchar Add2,uchar dat2) {
max7219_pincs=0;
Sent (ADD2);
Sent (DAT2);
max7219_pinclk=1; 16.5 clock cycles, data starting from the dout end of the first piece of MAX7219
Sent (REG_NO_OP); Empty operation on the first piece of MAX7219,
Sent (0x00);
Max7219_pincs=1;
}

This is not practical, I dare not imagine the number of lattice modules more cases. Rewrite as follows:

First define the number of modules

#define Max7219_nums 3

//-------------------------------------------
Function: Write data to MAX7219
Entry parameters: Chip: cascaded chip number, 0~max7219_nums-1
Address, DAT

void write_max7219 (Uchar chip, Uchar address, Uchar dat) {
int i;
max7219_pincs=0;
for (i=0;i<max7219_nums;i++) {
if (i==chip) {
Write_byte (address);
Write_byte (DAT);
} else {
Write_byte (REG_NO_OP); Empty operation,
Write_byte (REG_NO_OP); Empty operation
}
}
Max7219_pincs=1;
}

In addition, two functions can also be used as an example of the operation of a dot matrix using the above functions.

//-------------------------------------------
Function: Lattice screen initialization

Entry parameter: None

void Max7219_init (void) {
int i;
for (i=0;i<max7219_nums;i++) {
write_max7219 (i, 0x09, 0x00); Decoding method: BCD code
write_max7219 (i, 0x0a, 0x01); Brightness
write_max7219 (i, 0x0b, 0x07); Scanning limits; 8 x Digital Tube Display
write_max7219 (i, 0x0c, 0x01); Power-down mode: 0, Normal mode: 1
write_max7219 (i, 0x0f, 0x00); Display test: 1; end of test, normal display: 0
}
for (i=0;i<8*max7219_nums;i++)
write_max7219 (I/8, i%8+1, 0); Black screen
}

//-------------------------------------------
Function: Turn off the dot-matrix screen display

Entry parameter: None

void Max7219_sleep (void) {
int i;
for (i=0;i<8*max7219_nums;i++)
write_max7219 (I/8, i%8+1, 0); Black screen
for (i=0;i<max7219_nums;i++) {
write_max7219 (i, 0x0c, 0x00); Power-down mode: 0, Normal mode: 1
}
}

This article from "Tsing Lung Yan Yue" blog, reproduced please contact the author!

Dot Matrix large screen speech sensor--max7219 dot matrix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.