基于单片机的自动浇花器设计毕设论文
作者:互联网
#include<reg52.h>
#include<LCD1602.h>
#include<ADC0832.h>
#include<INTERRUPT.h>
#include<math.h>
#include<stdio.h>
#include<EEPROM.h>
#include<DS1302.h>
sbit jidainqi = P1^4;//自动浇花开关
sbit jidainqi_led = P1^3;//自动浇花开关指示灯
sbit key_mode = P3^2;//模式切换按键
sbit key_set = P3^3;//设置
sbit key_jia = P3^4;//加
sbit key_jian = P2^0;//减
sbit guang = P2^2;//光
uchar temp_ad[6];
double temp;
uchar f=0;
uchar wei;
uchar mode;
uchar set_time=0;
uchar jiaohua_num;//浇花湿度值
uchar set_shidu=0;//按键设置标志位
uchar T0_num;
uchar ad;
char naozhong1[]={0x00,0x00,0x00};
/********************************************************
函数名称:void delayms(uint ms)
函数作用:毫秒延时函数
参数说明:
********************************************************/
void Delay_ms(uint ms)
{
unsigned char i=100,j;
for(;ms;ms--)
{
while(--i)
{
j=10;
while(--j);
}
}
}
void display(void)//选择页面
{
lcd1602_write_character(0,1,"Watering System "); //初始化显示的文字
lcd1602_write_character(0,2," Choice mode"); //初始化显示的文字
}
void display1(void)//白天自动检测浇花
{
ad=ADC0832_read(0);
Delay_ms(25);
temp=(1-(double)ad/255)*100;
if(temp<=jiaohua_num)
{
if(f==0)//清屏标志位
{
LCD_write_command(0x01);
delay_n40us(100);
f=1;
}
lcd1602_write_character(0,1,"Flower is Dying!");
lcd1602_write_character(0,2," Auto Watering!");
jidainqi=0;jidainqi_led=0;//自动浇花
}
else
{
// if(temp<1.5)
// wei=sprintf(temp_ad,"%0.2f",0);
// else
wei=sprintf(temp_ad,"%0.2f",temp);
if(f==1)
{
LCD_write_command(0x01);
delay_n40us(100);
f=0;
}
lcd1602_write_character(0,1," The mode one:"); //初始化显示的文字
lcd1602_write_character(3,2," ");
lcd1602_write_character(9-wei,2,temp_ad);
lcd1602_write_character(9,2,"%RH");
jidainqi=1;jidainqi_led=1;//停止浇花
}
}
链接:https://pan.baidu.com/s/1l9PtAy880_xQ0q_-tbq3nQ
提取码:f2on
标签:毕设,浇花,uchar,character,write,单片机,lcd1602,sbit,include 来源: https://blog.csdn.net/m0_60139146/article/details/119007731