Today's experiment takes you to drive and use LED lattice through Arduino in Proteus and master the basic operation method of LED lattice.
The working principle of LED lattice will be explained after the experiment. Now let's do it first, drive the LED lattice, predict it, and then explore the reasons.
The first step is to run Proteus, and at the same time create a new Arduino 328 project, and name the project, here named LEDMatrix.
Step 2, find the LED lattice from the component library and add it to the workspace.
Click the "Component Mode" button on the left-click the "P" button-input matrix-in the input box-select photoelectric in the following category, and the search results will appear in the results window on the right.
We choose an 8×8 grid, and we can choose our favorite color.
Select the matrix -8×8- red here.
The third step is to place the LED lattice on the canvas designed by the schematic diagram.
At this time, we can observe that the LED lattice I * * has 64 LED beads, 8 rows and 8 columns; At the same time, there are 8 pins at the top and bottom.
Now an important problem is how to judge the function and connection mode of these 16 pins.
The easiest way is to search and consult the relevant data manual of LED lattice. Through simple research, we can know that two rows of pins of LED lattice, one row representing "row" and the other row representing "column", locate a light bulb through the intersection of one row and one column, and determine whether a light bulb is lit with "row high level and column low level" or vice versa. So which line of this LED lattice we choose is "row"? Which line is a column? Is the driving mode "row high and column low" or "row low and column high"?
Next, we will use a simple and small method to test and explore ourselves.
Tip: How to test the working mode of LED lattice?
We directly apply power and grounding to the different pins of the LED lattice module to observe the light emission of the LED lattice.
In terminal mode, select "Power Supply", place the power supply terminal, and set its characteristic to "VCC". Similarly, add a grounding terminal.
According to the figure below, complete the simplest connection, click the simulation button, and simulate and observe the running results.
Result analysis:
1. First, the upper row on the left is connected with high level, and the lower row is connected with low level. And the part connecting the low level and the high level on the right side is not bright.
2. Secondly, observe the lighted part on the left. 1, 2 columns and 1, 3 rows are lit, so the pins in the upper row are columns and the pins in the lower row are rows.
3. Conclusion: The pins in the upper row are columns, and the pins in the lower row are rows. The lighting mode is: the columns are high and the rows are low.
Step 4, connect the pin of the LED lattice module with the IO pin of Arduino. As shown below.
Step 5, write Arduino program in source code mode.
Lit function of litup () is defined in the program. In the loop () loop of the main function, the IO port number is passed into the litup () function as a parameter, and at the same time, the traversal of 64 positions is completed through the nesting of the for loop.
Operation effect:
A red light spot, starting from the upper left corner of the LED screen, moves from left to right along each line and automatically switches to the next line.
Thinking practice
1. How to display the number 3 on an 8×8 dot matrix screen?
2. How to make the grid light up all the lamp beads at once?