Not loading to LCD

My program upload to the board, but it does not display on the LCD.

Car_Parking_System_1.ino (1.3 KB)

Hi, @gamalmot
Can you post your code between code tags please?
To add code please click this link;

I have advised the moderators to move you to a more relevant section of the forum.

Tom.. :smiley: :+1: :coffee: :australia:

okay

What is code tag.

The </> button above a reply text box. See How to get the best out of this forum

Another way

  1. In the IDE, use tools -> autoformat to properly indent code
  2. In the IDE, use edit -> copy for forum to copy your code to the clipboard
  3. In a reply, paste what is on the clipboard

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

There are several libraries named LiquidCrystal_I2C. They are not all the same. You are using parts of different and incompatible LiquidCrystal_I2C libraries and there are many warnings generated as a result. I use the hd447780 library for all of my hd44780 character LCDs.

To install the hd44780 library. The hd44780 library is the best available for I2C LCDs. The library is available in the Library Manager. Go to Library Manager (in the IDE menus, Sketch, Include Libraries, Manage Libraries) and in the Topics dropdown choose Display and in the Filter your search box enter hd44780. Select and install the hd44780 library by Bill Perry.

In the examples, there is a diagnostic sketch that will help us to help you if you still have trouble with the display. Run the diagnostic sketch and post the results.

Here is your code modified to use the hd44780 library. This code has been tested on my Uno with a 16x2 I2C LCD and seems to work. The code has been formatted with the IDE auto format tool and properly posted in code tags (Read the forum guidelines.)

// Viral Science www.viralsciencecreativity.com www.youtube.com/c/viralscience
// Arduino Car Parking System

#include <Wire.h>
//#include <LiquidCrystal_I2C.h>
//LiquidCrystal_I2C lcd(0x27, 16, 2); //Change the HEX address

#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header

hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip

#include <Servo.h>

Servo myservo1;

int IR1 = 2;
int IR2 = 4;

int Slot = 4;           //Enter Total number of parking Slots

int flag1 = 0;
int flag2 = 0;

void setup()
{
   lcd.begin(16, 2);
   lcd.backlight();
   pinMode(IR1, INPUT);
   pinMode(IR2, INPUT);

   myservo1.attach(3);
   myservo1.write(100);

   lcd.setCursor (0, 0);
   lcd.print("     ARDUINO    ");
   lcd.setCursor (0, 1);
   lcd.print(" PARKING SYSTEM ");
   delay (2000);
   lcd.clear();
}

void loop()
{
   if (digitalRead (IR1) == LOW && flag1 == 0)
   {
      if (Slot > 0)
      {
         flag1 = 1;
         if (flag2 == 0)
         {
            myservo1.write(0);
            Slot = Slot - 1;
         }
      }
      else
      {
         lcd.setCursor (0, 0);
         lcd.print("    SORRY :(    ");
         lcd.setCursor (0, 1);
         lcd.print("  Parking Full  ");
         delay (3000);
         lcd.clear();
      }
   }

   if (digitalRead (IR2) == LOW && flag2 == 0)
   {
      flag2 = 1;
      if (flag1 == 0)
      {
         myservo1.write(0);
         Slot = Slot + 1;
      }
   }

   if (flag1 == 1 && flag2 == 1)
   {
      delay (1000);
      myservo1.write(100);
      flag1 = 0, flag2 = 0;
   }

   lcd.setCursor (0, 0);
   lcd.print("    WELCOME!    ");
   lcd.setCursor (0, 1);
   lcd.print("Slot Left: ");
   lcd.print(Slot);
}

If you still do not see anything, try adjusting the contrast pot on the I2C backpack.

Try:

// Viral Science www.viralsciencecreativity.com www.youtube.com/c/viralscience
// Arduino Car Parking System

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); //Change the HEX address
#include <Servo.h>

Servo myservo1;

int IR1 = 2;
int IR2 = 4;

int Slot = 4;           //Enter Total number of parking Slots

int flag1 = 0;
int flag2 = 0;

void setup()
{
  lcd.begin(16, 2);
  lcd.init();
  lcd.backlight();
  pinMode(IR1, INPUT);
  pinMode(IR2, INPUT);

  myservo1.attach(3);
  myservo1.write(100);

  lcd.setCursor (0, 0);
  lcd.print("     ARDUINO    ");
  lcd.setCursor (0, 1);
  lcd.print(" PARKING SYSTEM ");
  delay (2000);
  lcd.clear();
}

void loop()
{

  if (digitalRead (IR1) == LOW && flag1 == 0)
  {
    if (Slot > 0)
    {
      flag1 = 1;
      if (flag2 == 0)
      {
        myservo1.write(0);
        Slot = Slot - 1;
      }
    }
    else
    {
      lcd.setCursor (0, 0);
      lcd.print("    SORRY :(    ");
      lcd.setCursor (0, 1);
      lcd.print("  Parking Full  ");
      delay (3000);
      lcd.clear();
    }
  }

  if (digitalRead (IR2) == LOW && flag2 == 0)
  {
    flag2 = 1;
    if (flag1 == 0)
    {
      myservo1.write(0);
      Slot = Slot + 1;
    }
  }

  if (flag1 == 1 && flag2 == 1)
  {
    delay (1000);
    myservo1.write(100);
    flag1 = 0, flag2 = 0;
  }

  lcd.setCursor (0, 0);
  lcd.print("    WELCOME!    ");
  lcd.setCursor (0, 1);
  lcd.print("Slot Left: ");
  lcd.print(Slot);
}

Thanks a million Larry, the LCD lit up with the information. Tonight is my deadline and I have 3 hours left. Thanks again.

Gamal

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