Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
显示奇数字符的Arduino LCD_Arduino_Lcd - Fatal编程技术网

显示奇数字符的Arduino LCD

显示奇数字符的Arduino LCD,arduino,lcd,Arduino,Lcd,我正在使用LCD显示与土壤湿度传感器,它似乎使用以下返回的第一行字符奇数集 LCD.print("Soil Moisture"); //Print Message on First Row 尽管使用了以下方法,但效果非常好 LCD.print("Water level"); //Print Message on First Row 同样值得注意的是,它正确地打印到SerialMonitor上 刚开始学习Arduino时,我觉得这是一个错误,但我不能确定 整个代码如下: // Th

我正在使用LCD显示与土壤湿度传感器,它似乎使用以下返回的第一行字符奇数集

  LCD.print("Soil Moisture");  //Print Message on First Row
尽管使用了以下方法,但效果非常好

  LCD.print("Water level");  //Print Message on First Row
同样值得注意的是,它正确地打印到SerialMonitor上

刚开始学习Arduino时,我觉得这是一个错误,但我不能确定

整个代码如下:

// This sketch will use the soil moisture sensor and display the result on the LCD

#include <LiquidCrystal.h>
// include the LCD library
LiquidCrystal LCD(10, 9, 7, 6, 5, 4);
// Set pins as 10,9,7,6,5,4. It might be different for your LCD, check the producer catalog

int potPin = A0; //input pin
int soil = 0;
int percent = 0;

void setup() {
  Serial.begin(9600);
  LCD.begin(16,2); //Tell Arduino to start your 16 column 2 row LCD
  LCD.setCursor(0,0);  //Set LCD cursor to upper left corner, column 0, row 0
  LCD.print("Soil Moisture");  //Print Message on First Row
    delay(1000);
}
void loop() {
  // map the values
  int soil = analogRead(potPin) ;
  soil = constrain(soil, 600, 1023);
  soil = map(soil, 600, 1023, 0, 100);

  LCD.setCursor(0,1);
  //display final numbers
  LCD.print(soil);
  //print the percent symbol at the end
  LCD.print("%");
  //wait 0.1 seconds
  delay(75);
  //wipe the extra characters
  LCD.print(" ");

  Serial.print("Water level:");
  Serial.print(soil);
  Serial.println("%");
  delay(1000);
}
//此草图将使用土壤湿度传感器并在LCD上显示结果
#包括
//包括LCD库
液晶显示器(10,9,7,6,5,4);
//将销设置为10,9,7,6,5,4。您的LCD可能会有所不同,请查看生产商目录
int potPin=A0//输入引脚
int土壤=0;
整数百分比=0;
无效设置(){
Serial.begin(9600);
begin(16,2);//告诉Arduino启动16列2行LCD
setCursor(0,0);//将LCD光标设置到左上角第0列第0行
LCD.print(“土壤湿度”);//在第一行打印消息
延迟(1000);
}
void循环(){
//映射值
int soil=模拟读数(potPin);
土壤=约束(土壤,6001023);
土壤=地图(土壤,6001023,0100);
LCD.setCursor(0,1);
//显示最终数字
打印(土壤);
//在末尾打印百分比符号
LCD.打印(“%”);
//等待0.1秒
延误(75);
//删除多余的字符
LCD.打印(“”);
连续打印(“水位:”);
连载印刷品(土壤);
Serial.println(“%”);
延迟(1000);
}

它到底向您打印了什么?只是在本期中添加了一张照片。是的,很奇怪……我没有看到您的代码中有任何错误,也不明白为什么它使用了
LCD.print(“水位”)…除了
中有两个大写字母的“土壤湿度”
之外,这两个
字符串之间没有区别。在打印之前,您是否尝试过
清除
此显示器?是的,添加了lcd.clear,并且仍然保持
液晶lcd(10,9,7,6,5,4)必须适合您的接线。我猜你把这四条数据线搞乱了,否则它就根本不起作用了。尝试一个简单的“hello”或其他测试草图(例如,显示一个字符,每秒更改一次)它到底向您打印了什么?只是在问题中添加了一张照片。是的,很奇怪……我没有看到您的代码中有任何错误,也不理解为什么它使用
LCD。打印(“水位”)…除了
中有两个大写字母的“土壤湿度”
之外,这两个
字符串之间没有区别。在打印之前,您是否尝试过
清除
此显示器?是的,添加了lcd.clear,并且仍然保持
液晶lcd(10,9,7,6,5,4)必须适合您的接线。我猜你把这四条数据线搞乱了,否则它就根本不起作用了。尝试简单的“hello”或其他测试草图(例如,显示单个字符,每秒更改一次)