加入两个变量和LCD打印

Join two variable and LCD print

本文关键字:变量 LCD 打印 两个      更新时间:2023-10-16

我有一个可变名称day = 3。我想在LCD上打印为03。 如下

int term1;
int term2;
int day=3;
term1=day%10;// here i get the actual term day
term2=(int)(day/10). here i get term 0.

现在,我想通过加入TERM1和TERM2在LCD上打印。

lcd.print(concat(term1&term2)

问题是如何加入TERM1和项2以使结果显示为03而不是3

尝试这个。

lcd.print(term1);
lcd.print(term2);

您可以使用数组来存储Day

的值
char day_string[3];
int day;
if (day < 10)
{   
    // prepend a 0 to day if day is one digit
    day_string[0]='0';
    day_string[1]=day;
    day_string[2]='';
    lcd.print(day_string);
}
else
    // if day is a two digit value print itself 
    lcd.print(day);