数码管动态显示C语言程序

2020-05-22 科技 112阅读

原发布者:hwq551

//这是一个四位数码管动态显示c语言程序,每隔一秒加一,直至加到9999为止//使用时需采用锁存器#include#include"stdio.h"unsignedcharcodeLED[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};unsignedcharLEDbuff[]={0xff,0xff,0xff,0xff};//定义数码管的位选段sbitSEG_bit_1=P0^1;sbitSEG_bit_2=P0^2;sbitSEG_bit_3=P0^3;sbitSEG_bit_4=P0^4;unsignedintcnt=0;unsignedintsec=0;unsignedintmini=0;unsignedinthour=0;unsignedchari=0;/*voiddelay(unsignedintz){unsignedintx,y;for(x=z;x>0;x--)for(y=110;y>0;y--);}*/voidinterrupttimer0()interrupt1/*设置中断函数*/{TH0=0xfc;TL0=0x18;cnt++;//P1=0x80;//delay(1);switch(i){case0:SEG_bit_1=0;SEG_bit_4=1;P1=LEDbuff[0];i++;break;case1:SEG_bit_4=0;SEG_bit_3=1;P1=LEDbuff[1];i++;break;case2:SEG_bit_3=0;SEG_bit_2=1;P1=LEDbuff[2]&;i++;break;case3:SEG_bit_2=0;SEG_bit_1=1;P1=LEDbuff[3];i=0;break;default:break;}}/************************************************voidserial_init(){//TMOD=0x20;//定时器T/C1工作方式2SCON=0x50;//串口工作方式1,允许串口接收(SCON=0x40时禁止串口接收)TH1=0xF3;//
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com