LCD l2c have some voltage problem

The problem I have with LCD l2c screen when connected to an arduino and a button is that when the screen is connected to pin 13 and I run the code. I press the button and nothing happends... I change pin 13 to pin 5V and press the button it shows "PRESSED" and i change back to pin 13 then it turn on and off the screen but no text is displayed.

I think it is some voltage problem but i do not know what to change. This is how it is connected now.
IMG_0537

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);  // set the LCD address to 0x27

const int buttonPin = A1;
int lastButtonState;

void testButton() {
  int currentButtonState = digitalRead(buttonPin);

  if ((currentButtonState == LOW) && (lastButtonState == HIGH)) {
    digitalWrite(LED_BUILTIN, HIGH);
    lcd.print(F("PRESSED"));
    delay(15); // poor's man anti-bounce
  } else if ((currentButtonState == HIGH) && (lastButtonState == LOW)) {
    digitalWrite(LED_BUILTIN, LOW);
    delay(15); // poor's man anti-bounce
  }
  lastButtonState = currentButtonState;
}

void setup() {
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);
  // initialize the lcd
  lcd.init();
  lcd.backlight();
    lcd.setCursor(0, 0);
  lastButtonState = digitalRead(buttonPin);
}

void loop() {
  testButton();
}

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project :wink: See About the Installation & Troubleshooting category.

1 Like

You might need to add some delay after writing pin13 to HIGH so that the LCD display will become stable after which you can print anything on the LCD. I have seen that in the code there is no delay after enabling pin13.
Regards,

1 Like

I wonder if the display is still initialised after it was power cycled. Maybe a new lcd.begin() is needed before printing.

You will also have to do a current measurement to find out how much current your display draws; it might be too much for an Arduino pin.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.