#include “reg52.h” #include “LCD1602.h” #include “LCD1602.c” #include “ADC0832.h” #define uchar 无符号字符 #define uint 无符号 int sbit relay=P1^6;sbit keyAdd=P3^2;位键Dec=P3^3;uchar str[]=“Curret:00%”;uchar strV[]=“ Set:50%”;void delay_ms(uint xms);void main() { uchar i; uchar mCurrent; uchar mSet=50;LcdInt();Write_com(0x01);ÇåÆÁ delay_1602(5);写入地址(0x03);delay_1602(5);for(i=0;i<11;i++) { WriteData(str[i]); delay_1602(5); }写入地址(0x40);delay_1602(5);for(i=0;i<11;i++) { WriteData(strV[i]); delay_1602(5); } while(1) { if(keyAdd==0) { mSet++;写入地址(0x48);delay_1602(5);WriteData(mSet/10+0x30);delay_1602(5);WriteData(mSet%10+0x30);而(!keyAdd);} if(keyDec==0) { mSet--;写入地址(0x48);delay_1602(5);WriteData(mSet/10+0x30);delay_1602(5);WriteData(mSet%10+0x30);delay_1602(5);而(!keyDec);} mCurrent=ADC0832()*99/255;写入地址(0x08);写入数据(mCurrent/10+0x30);WriteData(mCurrent%10+0x30);if(mCurrent<mSet) 继电器=0;否则中继=1;delay_ms(200);} } void delay_ms(uint xms) { uint i,j; for(i=0;i<xms;i++) for(j=0;j<121;j++); }怎么把set这个改为ok
时间: 2023-07-30 07:09:02 浏览: 82
你需要在代码中将所有的 "mSet" 替换为 "ok",并且需要修改字符串数组 strV[] 为 " Ok:50%"。同时,你还需要修改按键的提示信息为 "Press OK to increase, Press DEC to decrease". 具体的修改如下所示:
```
#include “reg52.h”
#include “LCD1602.h”
#include “LCD1602.c”
#include “ADC0832.h”
#define uchar unsigned char
#define uint unsigned int
sbit relay=P1^6;
sbit keyAdd=P3^2;
sbit keyDec=P3^3;
uchar str[]=“Current:00%”;
uchar strV[]=“Ok:50%”;
void delay_ms(uint xms);
void main()
{
uchar i;
uchar mCurrent;
uchar ok=50;
LcdInit();
Write_com(0x01);
delay_1602(5);
WriteData(0x03);
delay_1602(5);
for(i=0;i<11;i++)
{
WriteData(str[i]);
delay_1602(5);
}
WriteData(0x40);
delay_1602(5);
for(i=0;i<11;i++)
{
WriteData(strV[i]);
delay_1602(5);
}
while(1)
{
if(keyAdd==0)
{
ok++;
WriteData(0x48);
delay_1602(5);
WriteData(ok/10+0x30);
delay_1602(5);
WriteData(ok%10+0x30);
while(!keyAdd);
}
if(keyDec==0)
{
ok--;
WriteData(0x48);
delay_1602(5);
WriteData(ok/10+0x30);
delay_1602(5);
WriteData(ok%10+0x30);
delay_1602(5);
while(!keyDec);
}
mCurrent=ADC0832()*99/255;
WriteData(0x08);
WriteData(mCurrent/10+0x30);
WriteData(mCurrent%10+0x30);
if(mCurrent<ok)
relay=0;
else
relay=1;
delay_ms(200);
}
}
void delay_ms(uint xms)
{
uint i,j;
for(i=0;i<xms;i++)
for(j=0;j<121;j++);
}
```
阅读全文