Four-digit frequency counter display design based on 51 microcontroller

Publisher:化羽2015Latest update time:2023-02-09 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Simulation schematic diagram:


Program operation chart:


Part of the program:


#include

#define uchar unsigned char

#define uint unsigned int

uchar duan[10]={0xc0,0Xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //The bit code of the required segment

//uchar wei[4]={0XEf,0XDf,0XBf,0X7f}; //bit control end (development board)

uchar wei[4]={0X80,0X40,0X20,0X10}; //bit control terminal (simulation)

uint z,x,c,v, date; //Define data type

uint dispcount=0;

uint lck=0;

uint disp=0;

/****************************************************** *****************


P2=wei[3];

P0=duan[v];

delay(50);


}


/****************************************************** ************************

Timer initial value 1ms

*************************************************** ************************/

void initTimer(void)

{

TMOD=0x0;

TH0=0xe3;

TL0=0xc;

}


/****************************************************** ************************

timer function

*************************************************** ************************/

void timer0(void) interrupt 1

{

TH0=0xe3;

TL0=0xc;

lck++;

if(lck==1000)

{

disp=dispcount;

lck=0;

dispcount=0;

}


}


/****************************************************** ************************

Interrupt function

*************************************************** ************************/

void int0(void) interrupt 0

{


dispcount++; //for each interrupt, the count increases by one


}


/****************************************************** ************************

main function

*************************************************** ************************/

void main(void)

{


IT0=1; //INT0 falling edge interrupt

EX0=1; //Allow INT1 interrupt

initTimer(); //Load the initial value

TR0=1;

ET0=1;

EA=1;

while(1)


{

date=disp;

xianshi();

}

}


Reference address:Four-digit frequency counter display design based on 51 microcontroller

Previous article:Design of intelligent car system based on 51 microcontroller
Next article:Design of sine wave generator based on 51 microcontroller

Latest Microcontroller Articles
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号