The digital tube display based on the single chip microcomputer realizes the self-adding function

Publisher:tnzph488Latest update time:2012-07-30 Source: 电子发烧友 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This article mainly introduces the self-increment function of the digital tube display based on the MCS-51 single-chip microcomputer, which displays from 1 to 999. The following is the hardware circuit diagram, function implementation diagram and source code. (Circuit: Use 74HC573 latch to control segment selection, 74H138 to control bit selection;)



Code to realize self-addition of digital tube:

#include

#define uchar unsigned char

#define uint unsigned int

uchar code table[16] = {0x3f,0x06,0x5b,0x4f,

0x66,0x6d,0x7d,0x07,0x7f,

0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; //Display digital table

uchar flag,bai,shi,ge;

uint temp;

void xunhuan();

void delay(uint z);

void init();

void main()

{

init();

while(1)

{

if(flag==20)

{

flag=0;

temp++;

if(temp==1000)

{

temp=0;

}

}

bai=temp/100;

shi=temp%100/10;[page]

ge=temp%10;

xunhuan();

}

}

void xunhuan()

{

P2=0;

P0=table[bai];

delay(30);

P2=1;

P0=table[shi];

delay(30);

P2=2;

P0=table[ge];

delay(30);

}

void init()

{

TMOD=0x01; //Timer 0

TH0=(65536-50000)/256; //timing 50ms

TL0=(65536-50000)%256;

EA=1;

ET0=1;

TR0=1;

}

void timer0() interrupt 1

{

TH0=(65536-50000)/256; //timing 50ms, 1m=1000ms=20*50ms

TL0=(65536-50000)%256;

flag++;

}

void delay(uint z)

{

uchar x,y;

for(x=z;x>0;x--)

for(y=110;y>0;y--);

}

Reference address:The digital tube display based on the single chip microcomputer realizes the self-adding function

Previous article:Microcontroller Teaching Based on Keil C51 Integrated Development Environment
Next article:Design of serial communication based on AT89C51 single chip microcomputer application 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号