Design and implementation of the function of running water lamp based on MCS-51 single chip microcomputer

Publisher:虚拟现实迷Latest update time:2014-02-18 Source: elecfansKeywords:MCS-51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Today, the editor will take you to continue to start from the basics and easily play with the MCS-51 microcontroller. The main function achieved this time is: the design and implementation of the running light function based on the STC89C51 microcontroller. As shown in the figure below: The figure below is the running light circuit (with the microcontroller interface setting). Circuit: The current value of 1 LED light tube is about 3~10mA, and the resistance value is 1K.

Marquee circuit (interface setting with single chip microcomputer)

  After the circuit is programmed, it can light up a single LED light or realize the function of running lights, marquee lights, etc. (You can write the specific program yourself) Here I have written a C source code to realize the running lights. You can also use your own divergent thinking to make the lights light up as you want... Those who have done it by themselves must have had this feeling: the board they bought has been used over and over again, but every time they come up with something new, and every time they write the code, they are completely immersed in it... The picture below shows what the board looks like when the specific function is realized. Let's take a look!

  The code to implement the water lamp:

  #include

  #include

  #define uchar unsigned char //Here "uchar" is used instead of "unsigned char", "uchar" is used to define unsigned character type numbers.

  #define uint unsigned int //"uint" is used to define unsigned integers.

  void delay(uint);

  uchar tmp,i;

  void main()

  { tmp=0x7f; //Turn on the 8th light (tmp=0x7f=0111 1111)

  P0=tmp;

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

  {

  tmp=_cror_(tmp,1); //Circularly shift right by 1 bit (tmp=1011 1111), light up the 7th light

  delay(500);

  P0=tmp;

  }

  P0=0xfe;

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

  {

  tmp=_crol_(tmp,1); //Circularly shift left by 1 bit

  delay(500);

  P0=tmp;

  }

  }

  void delay(z)

  { uint x,y;

  for(x=z;x>0;x--)

  for(y=110;y>0;y--);

  }

Keywords:MCS-51 Reference address:Design and implementation of the function of running water lamp based on MCS-51 single chip microcomputer

Previous article:Frequency meter hardware circuit diagram based on AT89C51
Next article:Design of universal controller based on RFID application

Recommended ReadingLatest update time:2024-11-23 21:26

Introduction to the CPU of MCS-51 single-chip microcomputer
The central processing unit (CPU) of the MCS-51 microcontroller is composed of an arithmetic unit and control logic, including several special function registers (SFRs). 1. ALU-centered arithmetic unit The arithmetic logic unit ALU can perform arithmetic operations such as addition, subtraction, multiplication,
[Microcontroller]
Introduction to the CPU of MCS-51 single-chip microcomputer
How many I/O ports does the MCS-51 microcontroller have? What are its components and features?
How many I/O ports does the MCS-51 microcontroller have? Answer: The MCS-51 microcontroller has four bidirectional 8-bit I/O ports, of which P0~P3 are tri-state bidirectional ports. P1, P2, and P3 ports are quasi-bidirectional ports (when used as input, the port line is pulled to a high level, so they are called q
[Microcontroller]
An article explaining the interrupt system of MCS-51 microcontroller in detail
MCS-51 interrupt system: 5 interrupt sources (two external interrupts, two timers, one serial port), 2 priorities Interrupt related concepts Interrupt: When the CPU is processing something, an emergency event that occurs outside or inside the microcontroller requires the CPU to handle it immediately. Therefore, the
[Microcontroller]
An article explaining the interrupt system of MCS-51 microcontroller in detail
Hardware Design of Serial Communication between PC and Multiple MCS-51 Single-Chip Microcomputers
1 Introduction In measurement and control systems and engineering applications, it is common to encounter situations where multiple tasks need to be executed simultaneously, so the master-slave multi-machine distributed system has become a widely used model in modern industry. Most of them are composed of IBM-PC micr
[Microcontroller]
Hardware Design of Serial Communication between PC and Multiple MCS-51 Single-Chip Microcomputers
Introduction to the characteristics of various types of MCS-51 series microcontrollers
MCS is the series symbol for the microcontrollers produced by Intel, for example, Intel's MCS-48, MCS-51, and MCS-96 series of microcontrollers. The MCS-51 series of microcontrollers was developed by Intel in the early 1980s on the basis of the MCS-48 series. It is the first mainstream variety of microcontrollers that
[Microcontroller]
Instruction timing of MCS-51 microcontroller
Timing is described using timing units. MCS-51 has four timing units: beat, state, machine cycle, and instruction cycle. We will explain each of them below. Beat and state: We define the period of the oscillation pulse as the beat (represented by P for the convenience of description). After the oscillatio
[Microcontroller]
Instruction timing of MCS-51 microcontroller
The structure of the MCS-51 interrupt system
The interrupt system of the 8031 ​​microcontroller is simple and practical. Its basic characteristics are: there are 5 fixed maskable interrupt sources, 3 on-chip and 2 off-chip. They each have a fixed interrupt entry address in the program memory, thereby entering the interrupt service program; the 5 interrupt source
[Microcontroller]
The structure of the MCS-51 interrupt system
Design of Interface between MCS-51 and Serial D/A Converter
1. Overview In microcomputer-controlled electrical equipment, it is often necessary to convert digital signals into analog signals to drive the operation of electrical equipment. In this process, D/A conversion is a very important link and an important component of the microcomputer control system. General D/A c
[Microcontroller]
Design of Interface between MCS-51 and Serial D/A Converter
Latest Microcontroller Articles
Change More Related Popular Components
Guess you like

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号