-
#include
#include
#define uchar unsigned char
#define uint unsigned int
#define
BB
480
#define port 0x01
#define Vdd 4.99
//============================================ =====
sbit lcden=P2^2;
sbit lcdrs=P2^0;
sbit lcdws=P2^1;
sbit P1_0=P3^0;
//
方波输出口
sbit AD_eoc=P1^3;
sbit AD_clk=P1^4;
sbit AD_add=P1^5;
sbit AD_dat=P1^6;
sbit AD_cs=P1^7;
//================================ =================
uchar code table[]=
uchar ge,shi,bai,qian;
uchar cd,temp[3];
uint t1,t2,t,num,m,ll,lll;
//====================== =============================
void delay(uint z);
void write_com(uchar com);
void write_data(uchar date);
void init0();
void init_x();
void transform();
void display();
//void jl();
uint ADC(uchar chn1);
//================== ==================================
void
main()
{
init0();
init_x();
while(1)
{
transform();
display();
//
显示电压值
//
write_com(0x80+0x4a);
delay(5);
}
}
//====================================== ================
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
//============== ========================================
void write_com(uchar com)
{
lcdrs=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
//=========== ==============================================
void write_data(uchar date)
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
//=========== ==============================================
void init0()
{
lcden=0;
lcdws=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
}
void init_x()
{
IE=0x82;
TMOD=0x01;
TH0=(65536-BB)/256;
TL0=(65536-BB)%256;
TR0=1;
}
//======================================= ====================
void transform()
{
num=ADC(port)*Vdd;
qian=num/1000%10;
bai=num/100%10;
shi=num/10%10;
ge=num%10;
ll=ADC(port)*Vdd;
ll=ll-0;
if(ll>1555&&ll<=1900)
lll=90;
if(ll>1380&&ll<=1555)
lll=100;
if(ll>1200&&ll<=1385)
lll=95;
if(ll>1100&&ll<=1200)
lll=105;
if(ll>1000&&ll<=1100)
lll=110;
if(ll>900&&ll<=1000)
lll=115;
if(ll>800&&ll<=900)
lll=120;
if(ll>740&&ll<=800)
lll=125;
if(ll>660&&ll<=740)
lll=130;
if(ll>600&&ll<=660)
lll=135;
if(ll>550&&ll<=600)
lll=140;
if(ll>490&&ll<=550)
lll=145;
-
-
-
-
-
-
-
-
本文更新与2021-01-25 15:23,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/566142.html
-
上一篇:2017华师在线作业英语教学理论96分
下一篇:以考代练的操作流程