欢迎来到天天文库
浏览记录
ID:47104230
大小:28.00 KB
页数:4页
时间:2019-08-03
《51单片机阳极数码管循环显示0~99的c程序 2》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include"reg51.h"#defineucharunsignedchar#defineuintunsignedintucharTab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};voiddelay(uintmount){uintj;for(;mount>0;mount--)for(j=0;j<125;j++){;}}voidmain(){uinti;uintcount=0;P0=0xc0;while(1){for(i=0;i<10;i++){P2=Tab[i];delay(500);}c
2、ount++;if(count==10)count=0;P0=Tab[count];}}#includeunsignedchartable[]={0x90,0x80,0xf8,0x82,0x92,0x99,0xb0,0xa4,0xf9,0xc0};unsignedcharint_time;unsignedcharsecond;voiddelay(void){unsignedchari,j;for(i=0;i<200;i++)for(j=0;j<20;j++);}voidDisplaySecond(unsignedchark){P2=0xf7;
3、P0=table[k/10];delay();P2=0xfb;P0=table[k%10];delay();P2=0xff;}voidmain(void){TMOD=0x01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;TR0=1;int_time=0;second=0;while(1){DisplaySecond(second);}}voidinterserve(void)interrupt1{TR0=0;int_time++;if(int_time==20){int_time=0;secon
4、d++;if(second==99)second=0;}TH0=(65536-50000)/256;TL0=(65536-50000)%256;TR0=1;}
此文档下载收益归作者所有