【发布时间】:2022-01-23 18:19:23
【问题描述】:
void printLCD(int col, int row , const char *str) {
for(int i=0 ; i < strlen(str) ; i++){
lcd.setCursor(col+i , row);
lcd.print(str[i]);
}
}
void loop(){
lightAmount = analogRead(0);
// Here
printLCD(0, 0, printf("Light amount: %d", lightAmount ));
}
我是 arduino 项目的 c 语言新手。
我想在 LCD 上显示"Light Amount: 222"。
但是printLCD函数中的第三个参数,它只能接收字符串类型,所以出错了。
如何在上述情况下同时显示变量和字符串?
【问题讨论】:
-
使用 Arduino
String类来处理字符串。哦,是的,Arduino 是用 C++ 编程的,而不是 C。