51 MCU tutorial: 51 MCU drives four 8*8 dot matrix

Publisher:数据探险家Latest update time:2022-01-27 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Dot matrix principle

There are many types of dot matrix on the market, but the most commonly used is this 8x8 dot matrix

insert image description here

The internal structure is as follows

insert image description here

It can be found that the dot matrix is ​​composed of LEDs, and one row is the anode, another row is the cathode, one row is the control row, and another row is the control column.

Open proteus and search for MATRIX. You will see various types of dot matrices. Select 8 by 8.

insert image description here

Choose a dot matrix of any color, and we find that the pins are not marked. By default, the upper row is cathode, control column; the lower row is anode, control row.

(Be sure to test it yourself, the direction of the dot matrix arranged by Proteus simulation may change every time)

insert image description here

What does it mean? It corresponds to the following figure, but the pin position has changed.

insert image description here

2. 4 "2x2" dot matrices are combined into a "4x4" dot matrix

Let's start with a simple understanding. First, draw four "2 by 2" dot matrixes.

insert image description here

Then connect the cathode control columns in the upper and lower directions

Connect the left and right anode control lines

It forms a 4*4 dot matrix

insert image description here

2. 4 "8 x 8" dot matrices form a "16 x 16" dot matrix

Note: The dot matrix of Proteus is really difficult to use. You can't find the direction and have to measure it yourself.

Measure two things: control column or control row, cathode or anode

insert image description here

3. Simulation: Display "turned into dust" in sequence, with an interval of 1 second


74hc138 and 74hc595 are used here. If you don't understand the principle, you can search it by yourself. I won't explain it here.

insert image description here
insert image description here
insert image description here

Corresponding code:


/*

HC595 and HC138 control 8*8 dot matrix

When I first wrote this program, the program took up more than 128 bytes of storage space.

mistake:

Dot matrix (IV) 16 times 16.C(98): error C249: 'DATA': SEGMENT TOO LARGE


The program cannot run because the array takes up a lot of memory.

Later, I added code before the array name to solve this problem.

This means that the array is stored in the program memory area (4 KB) instead of the data area (128 KB).

*/


#include


sbit SH_CP = P3^0;

sbit DS = P3^1;

sbit ST_CP = P3^2;


//The array that does not need to be changed is saved to the code program storage area

unsigned char code b[3][32] = {

/*-- Text: --*/

/*-- Songti 12; The corresponding dot matrix under this font is: width x height = 16x16 --*/

0x10,0x01,0x10,0x01,0x10,0x21,0x08,0x11,0x08,0x09,0x0C,0x05,0x0C,0x03,0x0A,0x01,

0x89,0x01,0x48,0x01,0x28,0x01,0x08,0x41,0x08,0x41,0x08,0x41,0x08,0x7E,0x08,0x00,


/*-- Text: --*/

/*-- Songti 12; The corresponding dot matrix under this font is: width x height = 16x16 --*/

0x90,0x00,0x90,0x00,0x90,0x00,0x88,0x7F,0x48,0x01,0x4C,0x01,0x2C,0x01,0x0A,0x1F,

0x09,0x01,0x08,0x01,0x08,0x01,0x08,0x3F,0x08,0x01,0x08,0x01,0x08,0x01,0x08,0x01,


/*-- Text: Dust --*/

/*-- Songti 12; The corresponding dot matrix under this font is: width x height = 16x16 --*/

0x80,0x00,0x80,0x00,0x90,0x04,0x90,0x08,0x88,0x10,0x84,0x20,0x82,0x20,0x00,0x00,

0x80,0x00,0x80,0x00,0xFC,0x1F,0x80,0x00,0x80,0x00,0x80,0x00,0xFF,0x7F,0x00,0x00,

  };


void delayms(unsigned int m)

{

int i,j;

for(i=0; i for(j=0; j<120; j++);

}


void hc_595(unsigned int temp,unsigned int temp1)   //595 segment code program

{

char t;

bit val;

for(t=0; t<8; t++)

{

   

val = temp & 0x80; //The first data is transmitted to the first 595 output

DS = val;

SH_CP = 0;;  

SH_CP = 1;

temp = temp<<1;

}

for(t=0; t<8; t++)

{

   

val = temp1 & 0x80; //The second data is transferred to the second 595 output

DS = val;

SH_CP = 0;;  

SH_CP = 1;

temp1 = temp1<<1;

}

ST_CP = 0;;   

ST_CP = 1;


void hc_138()

{

unsigned int n,t,i;

for(i=0; i<3; i++)   //Display 3 Chinese characters

{

for(t=0; t<30; t++)    // used to delay for 1 second

{

for(n=0; n<16; ++n)    //Display one Chinese character at a time

{

if(n<8) //The first high level of 138 moves down

{

P3_6 = 1; //The first 138 is enabled, the second 138 is not working

P2 = n;    

}

else //The second high level of 138 moves down

{

P3_6 = 0; //The second 138 is enabled, the first 138 does not work

P2 = n-8;    

}

hc_595(b[i][2*n],b[i][2*n+1]); //Send segment code

delayms(2);

}

}

}

}



void main(void)

{

while(1)

{

hc_138();

}

}

Reference address:51 MCU tutorial: 51 MCU drives four 8*8 dot matrix

Previous article:C51 tutorial second 51 program: Marquee and running lights
Next article:51 single chip microcomputer project design: ultrasonic ranging, smart car (keil+proteus)

Recommended posts

After the holiday, I will give you a review~~
Hello~Helloeveryone~Themanagerisheretosendinformationagain~~Comeandtakealookatthelatestsituation~~ Newactivitiesonline: 1.AnxinkeBluetoothDevelopmentBoardPB-02-Kit Activitiesintheapplicationperiod: 2.MirMYD-Y
okhxyyo Special Edition for Assessment Centres
What should I do if the RTC clock occasionally delays or times out?
Troubleshootingandanalysis1.TheindustrialcontrolboardusesNXP'sPCF8563RTCchipsolution,whichisanexternal32.768kHzquartzcrystalandcapacitor.TheoutputaccuracyoftheRTCchipdependsonwhethertheclockfrequencyoutputb
Aguilera Microcontroller MCU
Wearable network design solutions based on Bluetooth and ZigBee technologies
Wearablecomputersrequirethehosttobelightandsmallduetotheirwearability.ThehostchipusestheLinuxembeddedoperatingsystem,onwhichtheBluetoothprotocolstackisintegrated.Duetothecontradictionbetweenthemultimediastream
Jacktang Wireless Connectivity
Matters needing attention in the production of high-frequency microwave boards
1.Introduction   Withthecontinuousdevelopmentofscienceandtechnology,especiallyinformationtechnology,theprocesstechnologyofprintedcircuitboardproductionhasbeenimprovedaccordinglytomeettheneedsofdifferentusers.Inrecen
Jacktang Wireless Connectivity
《Rust in Action》vscode plugin installation
1、rust-analyzer 2、CodeLLDB 3.CatppuccinNoctisTheme 4、crates 5、ErroLens 6.EvenBetterTOMLSupportcompletefeaturesof.tomlfiles Rustylittlecrabhahaha Thankyouforyourattention,Rustisexcellent,butthereis
lugl4313820 Programming Basics
Analog Filter and Circuit Design Handbook
Averypracticalreferencebookonanalogfiltersandcircuitdesign. Thismanualisdividedinto19chapters,whichanalyzeanddiscussthedesignofvariousactiveandpassivefilters,computer-aideddesignoffilters,mathematicalcharacteris
arui1999 Download Centre
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号