8051 MCU (STC89C52) eight lights light up from the middle to both sides

Publisher:masphiaLatest update time:2021-08-11 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#include<STC89C5xRC.h>

void delay()//provide delay

{

    int i,j;

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

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

        {

            ;

        }

}

int main()

{

    while(1)

    {

    P2=0xFF; // All eight lights are off

delay();

P2=0xE7;

delay();

P2=0xC3;

delay();

P2=0x81;

delay();

P2=0;

delay();

    }

}

Design ideas:


1 1 1 1 1 1 1 1 //P2=0xFF  

1 1 1 0 0 1 1 1 //P2=0xE7  

1 1 0 0 0 0 1 1 //P2=0xC3  

1 0 0 0 0 0 0 1 //P2=0x81  

0 0 0 0 0 0 0 0 //P2=0   

Reference address:8051 MCU (STC89C52) eight lights light up from the middle to both sides

Previous article:Two-degree-of-freedom automatic sampling detector control (Version 1.1)
Next article:8051 MCU (STC89C52) countdown timer

Recommended ReadingLatest update time:2024-11-16 11:32

Precise signal simulation circuit design based on C8051F410 microcontroller
When testing a certain type of transmitting device. Three sets of accurate DC voltage signals referenced to 11.50 volts are required. In order to cooperate with the test process, these three sets of signals need to take 18 different DC voltage values ​​​​at different periods of time, with amplitudes distributed in the
[Microcontroller]
Precise signal simulation circuit design based on C8051F410 microcontroller
STC89C52 MCU DC motor debugging
///////////////////////////////////////////////////// ///////////////////////// Function: Configure timer 1 to generate an interrupt every 1 millisecond. By counting the number of interrupts,         the 0th pin of the defined P2 port generates a PWM with a duty cycle of 70%, which is used to drive the DC         mo
[Microcontroller]
Audio peak collection terminal design based on C8051F020 microcontroller and RTL8019AS
Broadcast signals go through program production and broadcasting, signal transmission, emission and other links, and are finally listened to at the audience's end. The system working status of each link will have an impact on the final broadcast quality. In order to comprehensively monitor the signal quality of multip
[Microcontroller]
Audio peak collection terminal design based on C8051F020 microcontroller and RTL8019AS
Design of embedded display system based on microcontroller C8051F120 and FPGA device
Relying on its affinity with users and natural human-computer interaction interface, embedded devices have developed rapidly and penetrated into every corner of life. The design method introduced in this article uses the high-performance 8-bit microcontroller C8051F120 as the core processor, SRAM as the system's video
[Microcontroller]
Design of embedded display system based on microcontroller C8051F120 and FPGA device
8051 MCU - Serial port simulation
The traditional 8051 series MCU is generally equipped with one serial port, and the STC89C52RC enhanced MCU is no exception. There is only one serial port available for use, which causes a problem. If the current MCU system requires two or more serial ports for simultaneous communication, it is very embarrassing for
[Microcontroller]
8051 MCU - Serial port simulation
C language programming of 8051 microcontroller
      8051 C programming is similar to traditional C programming. Of course, some data types are different. As we know, 8051 supports powerful bit addressing capabilities, so 8051 C programming adds some new data types to avoid wasting the capabilities of 8051. The following are the newly added data types.        bi
[Microcontroller]
C language programming of 8051 microcontroller
What does the 8051 microcontroller consist of? How many pins does the 8051 microcontroller have?
Introduction to 8051 microcontroller The 8051 microcontroller is an 8-bit microcontroller widely used in embedded systems. It was launched by Intel in 1980. It was one of the most advanced 8-bit microcontrollers in the industry at that time and a classic in the field of microcontrollers. The 8051 microcontroller has
[Microcontroller]
Design of Virtual Instrument Test System Based on C8051F120 Single Chip Microcomputer
1 Introduction Virtual instruments are computer-based instruments. The close integration of computers and instruments, and the construction of virtual instruments to replace complex and bulky analog instruments is the current trend of instrument development. Compared with traditional instruments, virtual instruments h
[Test Measurement]
Design of Virtual Instrument Test System Based on C8051F120 Single Chip Microcomputer
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号