您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > 51单片机ADC0804芯片AD转换通用程序
#includereg52.h#includeintrins.h#includeSTDIO.H#includehmzx.hADDateDate;uchari;ucharcodetable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};voidmain(){while(1){Init();ADStart();//启动A/D转换//P1=0xff;ADRead=0;Date.Val=P1;ADRead=1;//P1=Date.Val;for(i=30;i0;i--){display();}}}voidInit(void){WELA=1;P0=0;WELA=0;DULA=1;P0=0xff;DULA=0;}voidADStart(void){ADWrite=1;ADWrite=0;ADWrite=1;}voiddisplay(void){Date.Bai=Date.Val/100;//百位Date.Shi=Date.Val/10%10;//十位Date.Gei=Date.Val%10;//个位WELA=1;P0=0xfe;//第一位WELA=0;DULA=1;P0=table[Date.Bai];DULA=0;delay(5);WELA=1;P0=0xfd;//第二位WELA=0;DULA=1;P0=table[Date.Shi];DULA=0;delay(5);WELA=1;P0=0xfb;//第三位WELA=0;DULA=1;P0=table[Date.Gei];DULA=0;delay(5);}voiddelay(uintz){uintx,y;for(x=z;x0;x--)for(y=110;y0;y--);}
本文标题:51单片机ADC0804芯片AD转换通用程序
链接地址:https://www.777doc.com/doc-2345925 .html