程序如下:
#include<STC15.H>
#include"Delay.h"
#include"UART.h"
#include"IR_Receive.h"
#include"LCD1602.H"
#include"AirFan.h"
#include"DS18B20.h"
#include"intrins.h"
#define uchar unsigned char
#define uint unsigned int
#define u16 unsigned int
sbit BEEP=P1^1; //蜂鸣器驱动线
unsigned char ir_buf[4]; //用于保存解码结果
unsigned char limit_up=30,limit_dw=20;
unsigned char run_flag=1;
unsigned char rxbuf; //接收缓冲区
unsigned char speed=0;
unsigned char i=0;
float temperature;
bit rx_flag=0; //接收标志位
void Alarm(uchar t)
{
uchar i,j;
for(i=0;i<200;i++)
{
BEEP=~BEEP;
for(j=0;j<t;j++); //由参数t形成不同的频率
}
}
void main()
{
unsigned char rec_flag=0,i=0;
P5M0=0;P5M1=0; //设置P5.0~P5.7口为准双向口
P0M0=0;P0M1=0; //设置P0.0~P0.7口为准双向口
P1M0=0;P1M1=0; //设置P1.0~P1.7口为准双向口
P2M0=0;P2M1=0; //设置P2.0~P2.7口为准双向口
UART1_Init(); //波特率设置
LCD_Init(); //LCD1602初始化
AirFan_Init(); //风扇初始化
DS18B20_Init(); //DS18B20初始化
LCD1602_ClearLine(0);LCD1602_ClearLine(1); //清除一行
LCD1602_DisplayString(0,0,"Up: ℃ Dw: ℃"); //指定行、列和字符,显示字符温度上限 ℃,温度下限 ℃
LCD1602_DisplayString(1,0,"STA: ℃ Sp: ℃"); //指定行、列和字符,显示字符当前温度值 ℃,设定温度值 ℃
LCD1602_WriteNum(0,2,limit_up); //写温度上限值
LCD1602_WriteNum(0,11,limit_dw); //写温度下限值
LCD1602_WriteNum(1,12,speed); //写风速
LCD1602_DisplayString(1,4,"run"); //显示“run”,启动
while(1){
Delay_Nms(100);
while(!Ir_Pin); //为低电平时为未接收到数据,需要等待
rec_flag=IR_Delay_Receive_GetData(ir_buf); //接收数据,为1表明接收成功
if(rec_flag){ //接收成功后做出反应
rec_flag=0;
if(ir_buf[0]==0&&ir_buf[1]==0xff){ //校验
switch(ir_buf[2]){
case 0x45: //温度上限减1 (0100 0101)
limit_up--;
LCD1602_WriteNum(0,2,limit_up); //写减后温度上限值
break;
case 0x46: //温度上限加1 (0100 0110)
limit_up++;
LCD1602_WriteNum(0,2,limit_up); //写加后温度上限值
break;
case 0x44: //温度下限减1 (0100 0100)
limit_dw--;
LCD1602_WiriteNum(0,11,limit_dw); //写减后温度下限值
break;
case 0x40: //温度下限加1 (0100 0000)
limit_dw++;
LCD1602_WiriteNum(0,11,limit_dw); //写加后温度下限值
break;
case 0x43: //暂停、启动 (0100 0011)
if(run_flag){
LCD1602_DisplayString(1,4,"stop"); //显示暂停
AirFan_SetSpeed(0); //风速为0
run_flag=0; // run_flag=0为0表示当前为暂停状态,为1运行
}
else {
LCD1602_DisplayString(1,4,"run"); //显示启动
AifFan_Speed(speed); //风速
run_flag=1; //run_flag为0表示当前为暂停状态,为1运行
}
break;
case 0x15: //风速加10 (0001 0101)
if(speed<99) speed=speed+10;
LCD1602_DisplayString(1,12," ");
LCD1602_WriteNum(1,12,speed); //显示加后风速
if(run_flag)AirFan_SetSpeed(speed);
break;
case 0x07: //风速减10
if(speed>9) speed=speed-10;
LCD1602_DisplayString(1,12," ");
LCD1602_WriteNum(1,12,speed); //显示减后风速
if(run_flag) AirFan_SetSpeed(speed);
break;
default:break;
}
}
}
}
while(!DS18B20_Init());
while(1){
UART1_SendString("Temperature is");
temperature=DS18B20_GetTemperature();
UART1_SendNum_2point(temperature);
UART1_SendString(" ℃\n");
Deay200ms();
}
UART_Init();
EA=1;
while(1){
if(rx_flag){ //接收到数据,然后返回成功,说明实现蓝牙传输功能
rx_flag=0;
UART1_Send(rxbuf); //数据送回给PC
UART1_SendString(" Bluetooh transfer successfully\n");
}
}
BEEP=0;
while(1)
{
if(speed>50)
Alarm(90);
}
}
问题:
compiling MAIN.C...
..\SRC\MAIN.C(54): warning C206: 'LCD1602_ClearLine': missing function-prototype
..\SRC\MAIN.C(54): error C267: 'LCD1602_ClearLine': requires ANSI-style prototype
..\SRC\MAIN.C - 1 Error(s), 1 Warning(s).
|