51 MCU Introduction 4: Static Digital Tube

Publisher:心灵之舞Latest update time:2017-11-14 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

LED digital tube is a commonly used display device in the peripheral interface device of single-chip microcomputer. There are two types of display devices, seven-segment tube and Mi tube. The seven-segment tube is commonly used in the laboratory. There are two working modes: common cathode and common anode. The so-called common cathode is to connect the com end of the LED to the ground, and the common anode is to connect the com end to a high level. There are also two driving display modes: static display and dynamic display.

In static display, each digital tube occupies an eight-bit I/O port of the microcontroller, and the lit segment is always on during operation. In this way, the hardware circuit is simple, the programming is simple, but the I/O port of the microcontroller is wasted. The following is a brief demonstration of this driving method.

Connect a digital tube to port P2. The number displayed on the digital tube will automatically increase by one every second, and will be cleared to 0 after adding to 9, and the cycle will continue. In this experiment, the digital tube adopts the common cathode connection method.

The experimental principle diagram is as follows:


The experimental procedure is as follows:


[cpp]  view plain  copy

  1. #include  

  2. #define uchar unsigned char;  

  3. #define uint unsigned int;  

  4. uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //Common cathode digital tube data table  

  5. uchar a,i,j,z;  

  6.   

  7. void delay(z) //delay sub-function  

  8. {  

  9.    for(j=z;j>0;j--)  

  10.       for(i=110;i>0;i--);  

  11. }  

  12.   

  13. void main() //Main function  

  14. {  

  15.   while(1)  

  16.     {  

  17. for(a=0;a<10;a++) //From 0 to 9, a total of 10 cycles     

  18.      {  

  19.      P2=table[a]; //P2 port gets data from the data table  

  20.      delay(1000); //delay about 1s   

  21.       }        

  22.     }  

  23. }  


The test results are as follows:


Reference address:51 MCU Introduction 4: Static Digital Tube

Previous article:51 MCU Introduction 5: Digital Tube Display (Dynamic)
Next article:Microcontroller Easy Introduction Part 3: Buzzer

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号