Eight-way LED marquee experiment

Publisher:平静心境Latest update time:2023-06-06 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Now let's start the first experiment: an experiment in which eight light-emitting diodes light up in turn, which is commonly known as the marquee experiment. First, let us complete the necessary hardware part. We need to weld 8 light-emitting diodes and 8 For the current limiting resistor, you can refer to the schematic diagram and actual image below for operation. It should be noted that the LED has polarity. The long pin is the positive pole, and the short pin is the negative pole. The negative pole is connected to one side of the resistor. If connected If it is wrong, the corresponding path may not light up during the experiment. Please check it carefully before welding.

Next we will complete the software programming design. Here we do not use advanced programming skills, but use the stupidest and most direct method of sending numbers to the port. First of all, the program is relatively simple, there is no need to play deep, and beginners It seems intuitive and easy to understand.
ORG 0000H
START: MOV P1, #01111111B; The bottom LED lights up
LCALL DELAY; the delay is 1 second
MOV P1, #10111111B; the second bottom LED lights up
LCALL DELAY; the delay is 1 second
MOV P1, #11011111B ;The third LED at the bottom lights up (omitted below)
LCALL DELAY
MOV P1,#11101111B
LCALL DELAY
MOV P1,#11110111B
LCALL DELAY
MOV P1,#11111011B
LCALL DELAY
MOV P1,#11111101B
LCALL DELAY
MOV P1,#11111110B
LCALL DELAY
MOV P1, #11111111B; Complete the first cycle of lighting, with a delay of about 0.25 seconds
AJMP START; Cycle repeatedly
; Delay subroutine, 12M crystal oscillator delay of about 250 milliseconds
DELAY:
MOV R4, #2
L3: MOV R2, #250
L1: MOV R3 ,#250
L2: DJNZ R3 ,L2
DJNZ R2 ,L1
DJNZ R4 ,L3
RET
END This is the programmer
programming file obtained after the above program assembly : 201.hex How to download the programming file: Move the mouse to the super key link of the burning file, click the right button of the mouse, and select "Save target as (A)..." Do not select "Text file" as the save file type. You should select "All files", so that you can Got the *.hex file. How to accurately calculate the execution time of a delay subroutine?     One of the advantages of assembly language is that it can accurately control the execution time of the program, which is very important when writing some peripheral device drivers that have strict timing requirements! ;Delay subroutine, 12M crystal oscillator delay is about 253 milliseconds DELAY: MOV R4, #2---execute 1 machine cycle, taking 1 microsecond L3: MOV R2,#250---execute 1 Machine cycle, takes 1 microsecond L1: MOV R3, #251——Executes 1 machine cycle, takes 1 microsecond L2: DJNZ R3, L2——Execute 2 machine cycles, repeatedly executes 251 times (2x251 ) = 502 microseconds) DJNZ R2, L1---execute 2 machine cycles, repeatedly executed 250 times (1+502+2)*250=126250 microseconds) DJNZ R4, L3---execute 2 machine cycles, Repeatedly executed 2 times (1+1+502+126250+2)*2=253512 microseconds) RET delay plus the first one, the total delay is 1+253512=253513 microseconds
    












Reference address:Eight-way LED marquee experiment

Previous article:About the design of ATT7022B high-precision smart meter
Next article:Design and implementation of remote power safety measurement and control system

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号