永发信息网

请哪位C语言高手翻译一下程序,就在每一段标注一下。谢谢啦

答案:1  悬赏:60  手机版
解决时间 2021-01-03 04:04
  • 提问者网友:抽煙菂渘情少年
  • 2021-01-02 09:58
#include
#define uchar unsigned char
#define uint unsigned int
unsigned char code dispbitcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char dispbuf[4];
unsigned int i;
unsigned int j;
unsigned char getdata;
unsigned int temp;
unsigned int temp1;
unsigned char count;
unsigned char d;
sbit ST=P3^0;
sbit OE=P3^1;
sbit EOC=P3^2;
sbit CLK=P3^3;
sbit P34=P3^4;
sbit P35=P3^5;
sbit P36=P3^6;
sbit P20=P2^0;
sbit P21=P2^1;
sbit P22=P2^2;
sbit P23=P2^3;
sbit P17=P1^7;
sbit fwei1=P2^7;
sbit fwei2=P2^6;
sbit fwei3=P2^5;
sbit SPK1 = P0^0;
sbit SPK2 = P0^1;
sbit SPK3 = P0^2;
void TimeInitial();
void Delay(unsigned int i);

void TimeInitial()
{ TMOD=0x10;
TH1=(65536-200)/256;
TL1=(65536-200)%256;
EA=1;
ET1=1;
TR1=1;
}
void Delay(unsigned int i)
{
unsigned int j;
for(;i>0;i--)
{
for(j=0;j<125;j++)
{;}
}
}

void Display()

{
P1=dispbitcode[dispbuf[3]];
P20=0;
P21=1;
P22=1;
P23=1;
Delay(10);
P1=0x00;
P1=dispbitcode[dispbuf[2]];
P17=1;
P20=1;
P21=0;
P22=1;
P23=1;
Delay(10);
P1=0x00;
P1=dispbitcode[dispbuf[1]];
P20=1;
P21=1;
P22=0;
P23=1;
Delay(10);
P1=0x00;
P1=dispbitcode[dispbuf[0]];
P20=1;
P21=1;
P22=1;
P23=0;
Delay(10);
P1=0x00;
}
void main()
{
unsigned char t,a,b, h, m,n,k,p,q;
TimeInitial();
while(1)
{
ST=0;
OE=0;
ST=1;
ST=0;
P34=0;
P35=0;
P36=0;
while(EOC==0);
OE=1;
getdata=P0;
OE=0;
temp=getdata*1.0/255*500;
dispbuf[0]=temp%10;
dispbuf[1]=temp/10%10;
dispbuf[2]=temp/100%10;
dispbuf[3]=temp/1000;
Display();
if(getdata>0&&getdata<100)
{ fwei1=1;
fwei2=0;
fwei3=0;

for(a=0;a<200;a++)
{
SPK1 = ~SPK1;
for(b=0;b }
}
if(getdata>100&&getdata<200)
{ fwei1=0;
fwei2=1;
fwei3=0;

for(m=0;m<200;m++)
{
SPK2 = ~SPK2;
for(n=0;n }
}
if(getdata>200&&getdata<255)
{ fwei1=0;
fwei2=0;
fwei3=1;

for(p=0;p<200;p++)
{
SPK3 = ~SPK3;
for(q=0;q }
}
}
}

void t1(void) interrupt 3 using 0
{
TH1=(65536-200)/256;
TL1=(65536-200)%256;
CLK=~CLK;
}
最佳答案
  • 五星知识达人网友:痴妹与他
  • 2021-01-02 10:42
#include
#define uchar unsigned char
#define uint unsigned int
unsigned char code dispbitcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char dispbuf[4];
unsigned int i;
unsigned int j;
unsigned char getdata;
unsigned int temp;
unsigned int temp1;
unsigned char count;
unsigned char d;
//定义端口及其方向
sbit ST=P3^0;
sbit OE=P3^1;
sbit EOC=P3^2;
sbit CLK=P3^3;
sbit P34=P3^4;
sbit P35=P3^5;
sbit P36=P3^6;
sbit P20=P2^0;
sbit P21=P2^1;
sbit P22=P2^2;
sbit P23=P2^3;
sbit P17=P1^7;
sbit fwei1=P2^7;
sbit fwei2=P2^6;
sbit fwei3=P2^5;
sbit SPK1 = P0^0;
sbit SPK2 = P0^1;
sbit SPK3 = P0^2;
void TimeInitial();
void Delay(unsigned int i);
//定时设置
void TimeInitial()
{ TMOD=0x10;
TH1=(65536-200)/256;
TL1=(65536-200)%256;
EA=1;
ET1=1;
TR1=1;
}
void Delay(unsigned int i)
{
unsigned int j;
for(;i>0;i--)
{
for(j=0;j<125;j++)
{;}
}
}
//四个数码管逐次显示数字
void Display()

{
P1=dispbitcode[dispbuf[3]];
P20=0;
P21=1;
P22=1;
P23=1;
Delay(10);
P1=0x00;
P1=dispbitcode[dispbuf[2]];
P17=1;
P20=1;
P21=0;
P22=1;
P23=1;
Delay(10);
P1=0x00;
P1=dispbitcode[dispbuf[1]];
P20=1;
P21=1;
P22=0;
P23=1;
Delay(10);
P1=0x00;
P1=dispbitcode[dispbuf[0]];
P20=1;
P21=1;
P22=1;
P23=0;
Delay(10);
P1=0x00;
}
void main()
{
unsigned char t,a,b, h, m,n,k,p,q;
TimeInitial();
while(1)
{
ST=0;
OE=0;
ST=1;
ST=0;
P34=0;
P35=0;
P36=0;
while(EOC==0);
OE=1;
getdata=P0;//读取输入数据
OE=0;
temp=getdata*1.0/255*500;//数据值转换
//求取个十百千位上的数
dispbuf[0]=temp%10;
dispbuf[1]=temp/10%10;
dispbuf[2]=temp/100%10;
dispbuf[3]=temp/1000;
Display();//显示十进制各个位上的数
//getdata 在0~100 SPK1电平变换200次 100周期每周期时间与t有关
if(getdata>0&&getdata<100)
{ fwei1=1;
fwei2=0;
fwei3=0;

for(a=0;a<200;a++)
{
SPK1 = ~SPK1;
for(b=0;b }
}
//getdata 在100~200 SPK2电平变换200次 100周期每周期时间与h有关
if(getdata>100&&getdata<200)
{ fwei1=0;
fwei2=1;
fwei3=0;

for(m=0;m<200;m++)
{
SPK2 = ~SPK2;
for(n=0;n }
}
//getdata 200~255 SPK3电平变换200次 100周期每周期时间与k有关

if(getdata>200&&getdata<255)
{ fwei1=0;
fwei2=0;
fwei3=1;

for(p=0;p<200;p++)
{
SPK3 = ~SPK3;
for(q=0;q }
}
}
}
//定时中断控制时钟
void t1(void) interrupt 3 using 0
{
TH1=(65536-200)/256;
TL1=(65536-200)%256;
CLK=~CLK;
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯