RT 程序在下面 小弟菜鸟 PROTUSE没问题
作成实物就有问题了。调一下电位器 数值变化200。。。。。
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
code uchar seg7code[10]={ 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar wei[4]={0XEf,0XDf,0XBf,0X7f};
sbit ST=P3^0;
sbit OE=P3^1;
sbit EOC=P3^2;
sbit CLK=P3^3;
sbit jidian=P3^6;
sbit fengming=P3^7;
uint z,x,c,v,AD0809, date,flag=0;
void delay(uchar t)
{
uchar i,j;
for(i=0;i<t;i++)
{
for(j=13;j>0;j--);
{ ;
}
}
}
void xianshi()
{
uint z,x,c,v;
z=date/1000;
x=date%1000/100;
c=date%100/10;
v=date%10;
P2=0XFF;
P0=seg7code[z]&0x7f;
P2=wei[0];
delay(10);
P2=0XFF;
P0=seg7code[x];
P2=wei[1];
delay(10);
P2=0XFF;
P0=seg7code[c];
P2=wei[2];
delay(10);
P2=0XFF;
P0=seg7code[v];
P2=wei[3];
delay(10);
P2=0xff;
}
void timer0( ) interrupt 1
{
TH0=(65536-100)/256;
TL0=(65536-100)%256;
CLK=!CLK;
}
void timer1() interrupt 3
{
TH1=(65536-100)/256;
TL1=(65536-100)%256;
if(AD0809>=70)
{
flag=1;
}
else
{
flag=0;
}
}
void main()
{
TMOD=0X11;
CLK=0;
TH0=(65536-100)/256;
TL0=(65536-100)%256;
TH1=(65536-100)/256;
TL1=(65536-100)%256;
EA=1;
ET0=1;
ET1=1;
TR1=1;
TR0=1;
while(1)
{
ST=0;
ST=1;
ST=0;
while(!EOC);
OE=1;
AD0809=P1;
OE=0;
if(AD0809>=251)
AD0809=250;
date=AD0809;
xianshi();
if(flag)
{
jidian=0;
fengming=0;
}
else
{
jidian=1;
fengming=1;
}
}
}
附图:
ourdev_638259SVD1U5.jpg(文件大小:1.90M,只有400K以内的图片才能直接显示) (原文件名:我的截图.jpg)
求高手帮忙
-----------------------------------------------------------------------
哦
一周热门 更多>