I want to print the % sign on my LCD. Uses the lcd.print(“ C”); gives me two characters of four horizontal lines. Finding the binary values and converting these and using the lcd.print((char)37); and uploading this also gives me the same horizontal bars. Neither method displays the % I am after.
Any advice on how to fix this and making the readout to no decimal places?
Picture for reference.
Yeah but I think because of those 2 sets of four horizontal bars on the screen I just couldn't see it. When I got rid of the extra 2 decimal places the 2 sets of bars are still there but now I can see the % sign. Any idea how to get rid of the bars?
#include <dht.h> //DHT library
#include <LiquidCrystal_I2C.h>
dht DHT; //Declaring dht entity named DHT
LiquidCrystal_I2C lcd (0x27, 16, 2);
#define DHT11_PIN 11 //DHT data pin
void setup(){
}
void loop() {
Serial.begin(9600);
delay(10000);
int chk = DHT.read11(DHT11_PIN); //Read the data temperature from DHT11 pin
lcd.init();
lcd.backlight();
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temp ");
lcd.print(DHT.temperature, 0); //Showing temperature value
lcd.print(" C"); // print ° character
lcd.setCursor(0,1);
lcd.print("Humidity ");
lcd.println(DHT.humidity, 0); //Showing humidity percentage
lcd.print(" %");
}
Perhaps, you are executing:
lcd.println('%');
and not:
lcd.print('%');
lcd.println('%') sends the following three characters:
%,
non-printable CR (carriage return, ASCII code 0x0D), and
non-printable NL (newline, ASCII code 0x0A).
The two harizontal bar symbols are due to above 0x0D and 0x0A (Fig-1).
Figure-1:
Move all this into setup()…
change the line
to
lcd.print(DHT.humidity, 0); //Showing humidity percentage
and you will not get the lines anymore and have space for your %
Done! Thanks so much for the help. This is my first sketch!
Legend! Fixed thanks heaps