How to display variable char on the Arduino LCD?

Asked

Viewed 2,298 times

4

I was trying to print a variable char on the Antarctic LCD but I can’t, always error when I try to compile the code. I’ve pulled up the LCD library and the line I’m trying to print is next:

lcd.print("%c",letra);

What am I doing wrong? I thank you from now on!

  • 1

    It is also interesting to inform which error occurs!

1 answer

2


One thing that is important to know about Lcds displays is that they have an internal memory. The Arduino simply activates the read or write mode and sends a memory address with the character you want to print through the bus. The following figure shows the available characters:

inserir a descrição da imagem aqui

If you want to print a different character, there is another memory where you send an array of bytes containing the active and inactive pixels that will form your new character. As in the figure below:

inserir a descrição da imagem aqui

As for your problem, I think the following lines of code can solve:

//char variavel = 'a';
//lcd.print(char(variavel);     //Isto deveria funcionar
//lcd.print((char)223);         //Isto também

char caractere = 'b';
lcd.print(caractere, BIN);
//ou...
int charcode = 65;
lcd.print(charcode);

As the LCD receives a binary data, you must inform it through the "BIN". So the Arduino will send the binary value corresponding to the character through the bus.

  • 1

    Thank you! I haven’t tried the Internet itself but I’ve seen that I can compile, probably solved my problem!!

  • Thank you. If it doesn’t work, let me know. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.