0

Here my sample code for an Arduino Leonardo-based custom board:

#include <LiquidCrystal.h>

const int rs = 3, en = 0, d4 = 4, d5 = 30, d6 = 12, d7 = 6;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() 
{
  pinMode(2, OUTPUT);
  digitalWrite(2, LOW);
  
  Serial.begin(115200);

  lcd.begin(16, 2);
  lcd.print("Hello world");
}
 
void loop() 
{
} 

And here my schematic:

schematic

The MCU is an ATmega32U4. Running the code above the display is completely empty, I also tried to change the values of R4 and R5 but nothing changes. I don't see anything, not even the background of each character.

The display is a common HD44780 compatible one.

I retrieved the pin numbers from here:

/opt/arduino-1.8.19/hardware/arduino/avr/variants/leonardo/pins_arduino.h

Am I missing anything?

6
  • R4/5 should be a potentiometer not fixed resistors.
    – Majenko
    Mar 8, 2022 at 20:15
  • is the backlight lit? .... please post pictures of front and back of the LCD module
    – jsotola
    Mar 9, 2022 at 1:16
  • The schematic pin assignments do not match the Arduino Pin definitions you used in your code. Please see Arduino PinMapping32u4 or read the correct pin mapping for Leonardo from the source code.
    – hcheung
    Mar 9, 2022 at 4:16
  • @hcheung gosh, I used exactly those two documents to retrieve the pin assignment! Would you please tell me what is wrong? PD0=3, PD2=0, PD4=4, PD5=30, PD6=12, PD7=6. This is what I read from the header file.
    – Mark
    Mar 10, 2022 at 8:26
  • @hcheung I confirm the assignments are correct! There was only a hardware problem as "the busybee" pointed out
    – Mark
    Mar 10, 2022 at 8:46

1 Answer 1

3

The error is, that V0 has VDD level by the way you connected the resistors. The "lower end" of your ladder needs to be at GND, pin 1.

The pin 15 (A) is the anode of the backlight, and is not connected to the LCD driver circuit. BTW, to lit the backlight, you need to connect pin 16 (K), too. See the data sheet for details.

Use a potentiometer for V0, wiper to V0 and the ends to VDD and GND, respectively.

Just a side note: From the back of my memory, V0 can be commonly connected by a single resistor or directly to GND, since the wiper of the potentiometer was mostly at the GND end. It will give some contrast, depending on the temperature.

2
  • I'm trying right now and I'll write back soon. I assumed Vee was the negative rail, my fault. I don't want to put a pot otherwise I need to tune each board. I'm going to experiment and find the correct resistors ratio at room temperature.
    – Mark
    Mar 10, 2022 at 8:27
  • 1
    It works. With Vo = GND the contrast is perfect.
    – Mark
    Mar 10, 2022 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.