Simulate arduino driving dot matrix screen matrix-led in proteus

We all know that if we only light one digital tube for a certain period of time, there will be no difficulty, but if we light multiple digital tubes, there will be problems, because multiple digital tubes use the same port to control Each segment of the digital tube turns on and off. Therefore, a very important method will be used. Yes, this method is persistence of vision (human persistence of vision is 0.05~0.2 seconds), that is, we can use it to make people see multiple digital tubes. lit at the same time.

In order to master this method of visual persistence, our LED dot matrix screen is used as a column to introduce the use of this method.

Article source: https://blog.csdn.net/haigear/article/details/131524893

Some children may not be very familiar with the use of dot matrix screens, so let's start with the general use of dot matrix screens to understand how dot matrix screens display various patterns and graphics.

1. Wiring method of dot matrix screen

1. How to light up

First, we find matrix-8x8-Green in the device library, as shown below. Two points should be paid special attention to here:
1. The upper part is the control row, and the lower part is the control column;
2. The row must be connected to the negative electrode (GND), and the column must be connected to ( POWER) Positive pole
Insert image description here
Then, we found that the second and third columns of the third row were successfully lit.
Like this, it is very easy if we just choose to light up an nxm array. The positive and negative electrodes are connected to n rows and m columns respectively, as shown below (4x3 array):
Insert image description here

2. The embarrassment of displaying graphics

But if we want to display a graphic, even the simplest graphic of the number "0", I'm afraid there will be no way to do it. It seems that just removing the middle point is enough, as shown in the picture below:
Insert image description here
How is this display achieved? To tell you very straightforwardly, the above picture was synthesized in PS and cannot be realized using the above wiring.
So how can we achieve this? ? Then we need to use the visual persistence method we mentioned at the beginning of the article.

2. Implementation of graphic display

1. Principle of graphic display implementation

There is only one way to realize the graphics we need to display, which is to use visual persistence, that is, to light up all the points we need to light up once in a very short period of time (at least 0.2 seconds), regardless of whether they are lit up Whatever the order, just light it up. Our human eyes will naturally feel that this point is lit up. Of course, it will light up again every 0.2 seconds at least, so as to achieve the effect we want.

2. Simple graphics implementation

To realize the on-off control within the visual persistence time, it must be controlled by a microcontroller. Here we use Arduino for control. The chip used here is still 328p. The troublesome thing is that the dot matrix screen requires 8x2 ports, so here we have to use the analog port of arduino, otherwise the 13 digital ports cannot meet the requirements. The circuit connections are as follows:

Insert image description here
Running effect:

Insert image description here

3. Implement the code

int row[10]={
    
    2,2,2,3,4,5,5,5,4,3};
int col[10]={
    
    2,3,4,4,4,4,3,2,2,2};

void setup () {
    
    

// TODO: put your setup code here, to run once:
	for(int r=0;r<8;r++)
	{
    
    
	pinMode(r,OUTPUT);
	digitalWrite(r,1);
	}

	for(int c=8;c<16;c++)
	{
    
    
	pinMode(c,OUTPUT);
	digitalWrite(c,0);
	}

}

void loop() {
    
    

// TODO: put your main code here, to run repeatedly:

for(int i=0 ;i<10;i++)
{
    
    
	digitalWrite(row[i],0);
	digitalWrite(col[i]+7,1);
    delay(0.2);
    digitalWrite(row[i],1);
	digitalWrite(col[i]+7,0);
}

}

The graphics implemented by the above method have a simple idea, but in operation, it is quite troublesome to get the pin codes of the graphics. To change the graphics, we need to use arrays to describe their positive and negative pins one by one.
All, we will continue to introduce later, use the code generator to solve it, and then, in order to save pins, we can consider using the max7219 chip to implement scanning.

Interested children's shoes can continue to follow
. Creation is not easy. Please indicate the source for reprinting. The source of the article: https://blog.csdn.net/haigear/article/details/131524893

Guess you like

Origin blog.csdn.net/haigear/article/details/131524893