40 experiments of single chip microcomputer: left and right movement of advertising lights

Publisher:YuexiangLatest update time:2015-04-07 Source: eechinaKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Experimental task

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
 
Table 1

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 ;





Keywords:MCU Reference address:40 experiments of single chip microcomputer: left and right movement of advertising lights

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

AVR microcontroller learning experience
Recently I learned about the 8-bit microcontroller Mega8, which has the following features: a higher clock frequency than the 51 series microcontroller (16 MHz), and multiple working modes, including idle, power-down, power-saving, standby, sleep, etc. The clock can be set by fuses (external crystal oscillator, extern
[Microcontroller]
Detailed explanation of the difference between data, xdata and code of 51 MCU
dATa: Fixed to the first 128 RAM from 0x00 to 0x7f, can be directly read and written with acc, fastest speed, and the smallest generated code. idATa: Fixed to the first 256 RAM from 0x00 to 0xff, the first 128 are exactly the same as the 128 of dATa, just because of the different access methods. idATa is accessed in
[Microcontroller]
How to make an ISP download cable for AVR microcontroller
Homemade AVR MCU ISP Download Cable The function of the MCU programmer is to burn the debugged program into the memory of the MCU. The cost of the AVR MCU ISP download cable introduced in this article is only about 10 yuan, which is very suitable for beginners to make. The program of the AVR MCU can be downloaded and
[Microcontroller]
How to make an ISP download cable for AVR microcontroller
Why is embedded development more difficult than microcontroller development? That's so right
In fact, there is no standard definition to distinguish between microcontroller and embedded. For developers who have conducted microcontroller and embedded development, they all have their own definitions. Next, let’s talk about my understanding of these two concepts. and insights. First of all, clarify the concept
[Microcontroller]
Design of Distributed System Based on ARM Microcontroller LPC2138
introduction Distributed Control System (DCS) is a comprehensive network system that uses computer technology to centrally monitor, manage and decentralized control the production process. At present, the distributed control system built by using microcontroller as the distributed control core through RS485 n
[Microcontroller]
Design of Distributed System Based on ARM Microcontroller LPC2138
51 single chip microcomputer: LED light water lamp
After knowing the principle of flashing, we can output 0V, delay, and output 5V on all pins in sequence to achieve the effect of running lights, but this is too rigid. We can use the C language for loop and perform bit operations to achieve the effect simply. The program is as follows #include"reg52.h" //reference h
[Microcontroller]
51 single chip microcomputer: LED light water lamp
51 Microcontroller Basics GPIO Input
Code: #include reg52.h //Introduce header file sbit KEY=P3^1; //Define a button sbit LED=P2^0; //Define an LED light void delay(unsigned int u16) //Delay function, delay within 0.6 seconds {         while(u16--); } void main(void) //Main function, the program is executed from here {         while(1) //Code loo
[Microcontroller]
51 Microcontroller Basics GPIO Input
Research on the Setting and Application of MCU Reset Flag Bit
introduction Setting the reset flag bit is convenient for distinguishing resets caused by different reasons. As a new technology, it is adopted by more and more new microcontrollers. For example, the P87LPC700 and P89LPC900 series of Philips Company, the MC68HC05 series and MC68HC08 series of Freescale Company (form
[Microcontroller]
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号