Design of advertising lamp based on 51 single chip microcomputer

Publisher:oplndctkl出Latest update time:2017-12-31 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Experimental task
  : Use the table method to make the port P1 change a single light: move left 2 times, move right 2 times, and flash 2 times (delay time 0.2 seconds).
2. Circuit schematic diagram:
Advertising lights (using the meter-taking method)
                  Figure 4.5.1
3. Hardware connection on the system board : Connect P1.0-P1.7 in the
  " MCU system" area to the L1-L8 ports in the "Eight-way LED indicator 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. Program design content:
  When using the table for programming, the following instructions must be used to complete
(1). Use the MOV DPTR, #DATA16 instruction to make the data pointer register point to the beginning of the table.
(2). Use the MOVC A, @A + DPTR instruction to add the value of the accumulator to the value of the DPTR, so that the program counter PC can point to the data to be retrieved from the table.
  Therefore, as long as the control code is built into a table, and the MOVC function is used to perform the code retrieval operation, some complex control actions can be easily processed. The table retrieval process is shown in the figure below:
5. Program flowchart
Advertising lights (using the meter-taking method)
          Figure 4.5.2
6. Source program
                            ORG 0
START: MOV DPTR,#TABLE
LOOP: CLR A
                            MOVC A,@A+DPTR
                            CJNE A,#01H,LOOP1
                            JMP START
LOOP1: MOV P1,A
                           MOV R3,#20
                            LCALL DELAY
                            INC DPTR
                           JMP LOOP
DELAY: MOV R4,#20
D1: MOV R5,#248
                            DJNZ R5,$
                            DJNZ R4,D1
                           DJNZ R3,DELAY
                            RET
TABLE: DB 0FEH,0FDH,0FBH,0F7H
                            DB 0EFH,0DFH,0BFH,07FH
                           DB 0FEH,0FDH,0FBH,0F7H
                            DB 0EFH,0DFH,0BFH,07FH               
                           DB 07FH,0BFH,0DFH,0EFH
                            DB 0F7H,0FBH,0FDH,0FEH
                            DB 07FH,0BFH,0DFH,0EFH
                            DB 0F7H,0FBH,0FDH,0FEH
                            DB 00H, 0FFH,00H, 0FFH
                            DB 01H
                            END
7. C language source program
#include
unsigned char code table[]={0xfe,0xfd,0xfb,0xf7,
                            0xef,0xdf,0xbf,0x7f,
                            0xfe,0xfd,0xfb,0xf7,
                            0xef,0xdf,0xbf,0x7f, 0x7f,
                            0xbf,0xdf,0xef,
                            0xf7, 0xfb,0xfd,0xfe,
                            0x7f,0xbf,0xdf,0xef,
                            0xf7,0xfb,0xfd,0xfe,
                            0x00,0xff,0x00,0xff,
                            0x01};
unsigned char i;
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)
    {
      if(table[i]!=0x01)
        {
          P1=table[i];
          i++;
          delay();
        }
        else
          {
            i=0;
          }
    }
}

Reference address:Design of advertising lamp based on 51 single chip microcomputer

Previous article:The circuit design and program analysis of advertisement light left shift based on 51 single chip microcomputer
Next article:Design Principle and Analysis of Alarm Based on 51 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号