Three Methods of Controlling Marquee by MCS-51 Single Chip Microcomputer

In the MCS-51 microcontroller control system, its four parallel 8-bit input and output ports P0-P3 are often used. In the programming learning of the parallel port, the "horselight" is a typical example of the parallel port output control of the single chip microcomputer. The so-called marquee refers to connecting eight LEDs to eight lines of a parallel port of the MCU, and programming the eight LEDs to light up from low to high or high to low.

Three Methods of Controlling Marquee by MCS-51 Single Chip Microcomputer

Figure 1 Marquee circuit diagram

As shown in Figure 1, the eight LEDs are connected to the eight port lines of the P1 port of the MCS-51 microcontroller, and the anode is connected to the +5V power supply through a current limiting resistor. To make the LED light up, the corresponding port line should be low (''0'); to turn it off, the corresponding terminal I=I line should be high ("1"). Therefore, we assume that the "horselight" is illuminated by the low end of the terminal I = 1 to the high position. Can get the following status:

Table 1 Marquee Status Table

Three Methods of Controlling Marquee by MCS-51 Single Chip Microcomputer

As can be seen from Table 1, there are 8 states of the P1 port, which are displayed during the "horselight" display. These eight states appear in sequence, looping back and forth. And to achieve this display function of "horse lights". We can use three methods:

(1) Exhaustive law;

(2) displacement method;

(3) Check the table method.

Let's introduce these three methods separately.

First, the exhaustive law

For the display state of the microcontroller, its eight states are cyclically displayed. The so-called exhaustive law. It refers to enumerating all the display states of the microcontroller. Written in the main function of the program, the loop display of these states is realized by the infinite loop of while(1).

The procedure is as follows:

#include<reg51. h> //Time delay function. Delay 0.5s

Voiddelay()

{

Three Methods of Controlling Marquee by MCS-51 Single Chip Microcomputer

It can be seen from the above procedure that the exhaustive program has a simple structure. Simply list all the required states in the main function.

10000 Puffs Vape

Guangzhou Yunge Tianhong Electronic Technology Co., Ltd , https://www.e-cigarettesfactory.com