Arduino LCD показывает нечетные символы - PullRequest
1 голос
/ 14 июня 2019

Я использую ЖК-дисплей с датчиком влажности почвы, и кажется, что при использовании следующего возвращается нечетный набор символов в первой строке.

  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);
}

enter image description here

...