📄 ad及液晶显示.c
字号:
#include<AT89X51.H>
#include<LCD1602.H>
void delay(unsigned int count);
unsigned char adr(bit n);
sbit oe=P3^0;
sbit eoc=P3^1;
sbit start=P3^2;
sbit adda=P3^3;
unsigned char tc,ds=0x04;
bit flag=0;
unsigned char k=196;
unsigned int a0,a1;
void main()
{
TMOD=0x01;
TH0=0x4c;
TH0=0x00;
IE=0x82;
tc=ds;
TR0=1;
do
{
if(flag==1)
{
flag=0;
a0=adr(0)*k;
a1=adr(1)*k;
LCD_initial();
LCD_set_position(0);
LCD_prints("U0=");
LCD_printc(0x30+a0/10000);
LCD_printc(0x2e);
LCD_printc(0x30+a0%10000/1000);
LCD_printc(0x30+a0%1000/100);
LCD_printc(0x30+a0%100/10);
LCD_printc(0x30+a0%10);
LCD_set_position(0x40);
LCD_prints("U1=");
LCD_printc(0x30+a1/10000);
LCD_printc(0x2e);
LCD_printc(0x30+a1%10000/1000);
LCD_printc(0x30+a1%1000/100);
LCD_printc(0x30+a1%100/10);
LCD_printc(0x30+a1%10);
}
}while(1);
}
void time0(void) interrupt 1 using 1
{
TH0=0x4c;
tc--;
if(tc==0)
{
tc=ds;
flag=1;
}
}
unsigned char adr(bit n)
{
unsigned char ads;
oe=0;
start=0;
adda=n;
start=1;
start=0;
do
{
}while(eoc==0);
oe=1;
ads=P0;
oe=0;
return(ads);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -