Move a single light left and right. The hardware circuit is shown in Figure 4.4.1. The eight LEDs L1-L8 are connected to the P1.0-P1.7 interfaces of the single-chip computer. When the output is "0", the LED lights up. At the beginning, P1.0→P1.1→P1.2→P1.3→┅→P1.7→P1.6→┅→P1.0 lights up, and the cycle repeats.
2. Circuit schematic diagram
3. Hardware connection on the system board
Connect P1.0-P1.7 in the "single-chip computer system" area to the L1-L8 ports in the "eight-way LED indication module" area with an 8-core cable. The requirements are: P1.0 corresponds to L1, P1.1 corresponds to L2, ..., P1.7 corresponds to L8.
4. Programming content
We can use the output port instruction MOV P1, A or MOV P1, #DATA. As long as we give the accumulator value or constant value and then execute the above instruction, we can achieve the output control action. [page]
The data sent each time is different. The specific data is shown in Table 1 below:
P1.7 |
P1.6 |
P1.5 |
P1.4 |
P1.3 |
P1.2 |
P1.1 |
P1.0 |
illustrate |
L8 |
L7 |
L6 |
L5 |
L4 |
L3 |
L2 |
L1 |
|
1 |
1 |
1 |
1 |
1 |
1 |
1 |
0 |
L1 Bright |
1 |
1 |
1 |
1 |
1 |
1 |
0 |
1 |
L2 Bright |
1 |
1 |
1 |
1 |
1 |
0 |
1 |
1 |
L3 Bright |
1 |
1 |
1 |
1 |
0 |
1 |
1 |
1 |
L4 Bright |
1 |
1 |
1 |
0 |
1 |
1 |
1 |
1 |
L5 Bright |
1 |
1 |
0 |
1 |
1 |
1 |
1 |
1 |
L6 Bright |
1 |
0 |
1 |
1 |
1 |
1 |
1 |
1 |
L7 Bright |
0 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
L8 Bright |
5. Program flow chart
6. Assembly source program
ORG 0
START: MOV R2,#8
MOV A,#0FEH
SETB C
LOOP: MOV P1,A
LCALL DELAY
RLC A
DJNZ R2,LOOP
MOV R2,#8
LOOP1: MOV P1,A
LCALL DELAY
RRC A
DJNZ R2,LOOP1
LJMP START
DELAY: MOV R5,#20 ;
D1: MOV R6,#20
D2: MOV R7,#248
DJNZ R7,$
DJNZ R6,D2
DJNZ R5,D1
RET
END
7. C language source program
#include
unsigned char i;
unsigned char temp;
unsigned char a,b;
void delay(void)
{
unsigned char m,n,s;
for(m=20;m>0;m--)
for(n=20;n>0;n--)
for(s=248;s>0;s--);
}
void main(void)
{
while(1)
{
temp= 0xfe;
P1=temp;
delay();
for(i=1;i<8 ;i++)
{ a=temp< ;
b=temp>>(8-i); P1 =a|b;
delay
(); }
for
(i=1;i<8;i++) {
a
=temp>> i ;
Previous article:40 experiments on single chip microcomputer: key recognition method
Next article:40 experiments on single chip microcomputer: key recognition method
Recommended ReadingLatest update time:2024-11-16 14:38
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Learning ARM-LINUX embedded system based on Beaglebone Black Part 2 - JTAG debugging
- EEWORLD University Hall ---- EDA Technology and Experiments Zhu Min from Harbin Institute of Technology
- Hot topic: The four most popular and profitable majors in the 5G era, which you definitely can’t miss in the 2019 college entrance examination!
- How to read constant array in flash using IAR FOR AVR?
- Technology Live: MEMS sensors usher in a new era of condition monitoring, ADI takes you into the kingdom of cold machines
- Analysis of the working principles of seven triode collector DC circuits 3
- Explore RF challenges and solutions for the connected car
- 40 Years of Mobile Base Station History
- 【RT-Thread Reading Notes】Network Framework
- Altium Designer 17 version experience sharing (updated from time to time)