LCD Not working

Hi all. I am trying a project for a guitar looper pedal. My new lcd screen powers on and has backlight, however, nothing is displayed in terms of writing on the screen. I have tested with hello world and the lcd works. It appears to be a programming issue.

The pins are labelled a little differently on this LCD:

1 VSS VDD VO RS RW E D0 D1 D2 D3 D4 D5 D6 D7 A K 16

Instead of EN it has an E, being new to this I am not sure how this will affect the workings of this with the programming. Bear in mind I did not write the program and therefore, the original program would have been written for a different brand of screen. I have looked in the LCD Library and everything refers to EN instead of E.

Not sure what to do.

The code for the pedal looper is as follows:

/* programable stompbox looper. Original design and sketch by CarraN. Corrected, updated and upgraded by Pascal Paquay */

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <EEPROM.h>
#include <Keypad.h>
LiquidCrystal_I2C  lcd(0x27,2,1,0,4,5,6,7); /* set the LCD address to 0x27 for a 16 chars and 2 line display. 
any other display can be used,just change parameters. */
const byte rows = 8; /*change it the same value as numberOfPedal variable */
const byte cols = 3;
char keys[rows][cols] = {
{'a','i','q'},
{'b','j','r'},
{'c','k','s'},
{'d','l','t'},
{'e','m','u'},
{'f','n','v'},
{'g','o','w'},
{'h','p','x'} /* {'y','z','0'}, {'1','2','3'}, {'*','%','!'} add more characters if needed */
};

byte rowPins[rows] = {22, 23, 24,25, 26,27, 28, 29};
byte colPins[cols] = {30, 31, 32};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);
int relayPin[8] = {33,34,35,36,37,38,39,40};
int ledPin[8] = {41,42,43,44,45,46,47,48};
byte midiChannel = 0;
int i;
int readOut;
int numberOfPedal = 8; /*adapt this number to your needs = number of loop pedals */

/******************************************************/

void setup()
{
  for(i=0; i<numberOfPedal; i++)
   {
    pinMode(relayPin[i], OUTPUT);
    pinMode(ledPin[i], OUTPUT);
    digitalWrite(relayPin[i],HIGH); //pullup all relay outputs in case off low level relayboard
   }
Serial.begin(31250); /* for midi communication - pin 1 TX */
/*for (int i = 0; i < 512; i++) // erase eeprom (optional)
// EEPROM.write(i, 0); */
lcd.begin (16,2); // for 16 x 2 LCD module
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH);
lcd.print("Stompbox looper");
lcd.setCursor(0,1);
lcd.print("Pascal & CarraN");
delay(200);
}

/*********************************************************/

void midiProg(byte status, int data)
{
Serial.write(status);
Serial.write(data);
}

/*********************************************************/

void memory(int addr, int led)
{
  for(i=0; i<numberOfPedal; i++)
    {
      EEPROM.write((addr) + i, digitalRead(relayPin[i]));
      digitalWrite(ledPin[i], LOW);
    }
lcd.clear();lcd.print("Stored at ");
lcd.print(led + 1);
delay(100);
digitalWrite(ledPin[led], HIGH);
delay(100);
digitalWrite(ledPin[led], LOW);
delay(100);
digitalWrite(ledPin[led], HIGH);
delay(100);
digitalWrite(ledPin[led], LOW);
delay(100);
digitalWrite(ledPin[led], HIGH);
delay(100);
digitalWrite(ledPin[led], LOW);
delay(100);
digitalWrite(ledPin[led], HIGH);
lcd.clear();
}

/*********************************************************/

void writeOut(int relay)
{
  digitalWrite(relayPin[relay], !digitalRead(relayPin[relay]));
  digitalWrite(ledPin[relay], !digitalRead(relayPin[relay]));
  lcd.clear();
  lcd.print(" loop FX ");
  lcd.print(relay + 1);
}

/*********************************************************/

void readPreset(int addr, int pcNum, int led)
{
  for(i=0; i<numberOfPedal; i++)
  {
    digitalWrite(relayPin[i], EEPROM.read((addr)+i));
    digitalWrite(ledPin[i], LOW);
    digitalWrite(ledPin[led], HIGH);
   }
   lcd.clear();
   lcd.print(" Preset ");
   lcd.print(led + 1);
   midiProg(0xC0, pcNum +1); /* send midi change program 1 */
}

/******************************************************/

void loop()
{
char key = keypad.getKey();
if(key) // Check for a valid key.
  {
   switch (key)
    {
     case 'a': /* 'a' to 'h' for 8 pedals- adapt it to the number you needs */
      writeOut(0);
      break;
     case 'b':
      writeOut(1); /* (relay number,led number) */
      break;
     case 'c':
      writeOut(2);
      break;
     case 'd':
      writeOut(3);
      break;
     case 'e':
      writeOut(4);
      break;
     case 'f':
      writeOut(5);
      break;
     case 'g':
      writeOut(6);
      break;
     case 'h':
      writeOut(7);
      break;
/****************************** STORE PRESET MODE */
     case 'i': /* same remark as previous */
      memory(11,0);
      break;
     case 'j':
      memory(21,1); /* (EEPROM address, led) */
      break;
     case 'k':
      memory(31,2);
      break;
     case 'l':
      memory(41,3);
      break;
     case 'm':
      memory(51,4);
      break;
     case 'n':
      memory(61,5);
      break;
     case 'o':
      memory(71,6);
      break;
     case 'p':
      memory(81,7);
      break;
/****************************** READ PRESET MODE (EEProm address,PcNum,led number)*/
     case 'q':
      readPreset(11, 1, 0); 
      break;
     case 'r':
      readPreset(21, 2, 1);
      break;
     case 's':
      readPreset(31, 3, 2);
      break;
     case 't':
      readPreset(41, 4, 3);
      break;
     case 'u':
      readPreset(51, 5, 4);
      break;
     case 'v':
      readPreset(61, 6, 5);
      break;
     case 'w':
      readPreset(71, 7, 6);
      break;
     case 'x':
      readPreset(81, 8, 7);
      break;
      }
    }
}

E and EN are the same thing. That pin is the enable pin.
The Hitachi hd44780 LCD datasheet calls it "E" but others call it "EN".
It is the same thing.
The newLiquidCrystal library (which you appear to be using) calls it "En".

Keep in mind that there are MANY libraries out there that include a "LiquidCrystal_I2C" library class.
They have slightly different API functions, they are initialized slightly differently, and are configured differently.

In terms of why it isn't working, it is likely that you have initialized the library incorrectly, especially since you said the HelloWorld works.

With the library you appear to be using (which I'm guessing based on the constructor you are using),
you must tell it the i2c address and the pin mapping used on the backpack.
If those are incorrect, then it won't work.
The helloworld must be using different parameters in the lcd object constructor.

LiquidCrystal_I2C  lcd(0x27,2,1,0,4,5,6,7);

You could use my hd44780 library which will automatically figure out the library configuration parameters.
It is available in the IDE library manager and can be installed from the IDE GUI quickly and easily.
(no need to mess with any zip files or manual installation).
You can read more about it here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
The i/o class for that type of backpack is hd44780_I2Cexp
The first sketch you should run is I2CexpDiag to verify that the library and the backpack are functioning properly.

To modify the code you have to use it:
Use these includes and lcd object declaration:

#include <Wire.h>
#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 & config exapander chip

Then remove these lines:

lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH);

Use lcd.backlight() and lcd.noBacklight() to turn the backlight on/off.
By default the backlight will be on when lcd.begin() returns.

--- bill

Hi bperrybap,

I will give this a try. sounds a bit complex as I am not good at all this programming stuff. I am a guitarist and have a little practical electronics knowledge, Programming is all new but I will try that.

Many thanks. I will keep updating the progress.

The hello world I tested was using this configuration:

RS pin 1
EN pin 2
D4 pin 4
D5 pin 5
D6 pin 6
D7 pin 7

Does that mean I should configure my pins similarly and also edit this line from:

LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);

to this line:

LiquidCrystal_I2C(1, 2, 4, 5, 6, 7)

If that is the case, will it stop anything else working if I edit the line?

Below is the code for Hello world that i used successfully

 /*
* Arduino LCD Tutorial
*
* Crated by Dejan Nedelkovski,
* www.HowToMechatronics.com
*
*/
#include <LiquidCrystal.h> // includes the LiquidCrystal Library 
LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7) 
void setup() { 
 lcd.begin(16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display } 
}
void loop() { 
 lcd.print("Arduino"); // Prints "Arduino" on the LCD 
 delay(3000); // 3 seconds delay 
 lcd.setCursor(2,1); // Sets the location at which subsequent text written to the LCD will be displayed 
 lcd.print("LCD Tutorial"); 
 delay(3000); 
 lcd.clear(); // Clears the display 
 lcd.blink(); //Displays the blinking LCD cursor 
 delay(4000); 
 lcd.setCursor(7,1); 
 delay(3000); 
 lcd.noBlink(); // Turns off the blinking LCD cursor 
 lcd.cursor(); // Displays an underscore (line) at the position to which the next character will be written 
 delay(4000); 
 lcd.noCursor(); // Hides the LCD cursor 
 lcd.clear(); // Clears the LCD screen 
}

The hello world you showed in response #3 is for a totally different LCD library and different electrical interface to the LCD than the code shown in the first post.
The code in the first post was using an LCD library that is expecting to talk to an LCD that is wired to an i2c backpack and then using the Wire library to talk to the i2c backpack.
The code in response #3 is using a library that is expecting to talk to an LCD that is wired directly to Arduino pins.

Notice the difference in the files included with #include.
In particular, one uses LiquidCrystal.h and the other uses LiquidCrystal_I2C.h
Those are header files for two different libraries.
Also, notice the lcd object declaration and constructor.

LiquidCrystal lcd(1, 2, 4, 5, 6, 7);

VS

LiquidCrystal_I2C  lcd(0x27,2,1,0,4,5,6,7);

They are the declarations for two different libraries that expect different electrical connections to the LCD.

If your LCD is wired up directly to Arduino pins you will need to use the LiquidCrystal library and must use the LiquidCrystal include and declare a LiquidCrystal object with the appropriate constructor parameters.
The LiquidCrystal library does not support backlight control so you must remove the backlight control methods from the code.
i.e. these lines.

lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH);

-- bill

Hi Bill,

I have followed your advice and replaced the I2c library with the liduid crystal library. I have also modified the code to reflect the new library being used and deleted the refernce lines to backlighting.

The code compiles with no errors.

Bear in mind I have not connected everything to the Arduino board (ie no pedals or switches, just the lcd), The screen turns on but no writing on it. In the modified code below, should I not at least see this:

"Stompbox looper"
"Pascal & CarraN"

??

when I adjust the contrast I see what is on the attached image instead.

/* programable stompbox looper. Original design and sketch by CarraN. Corrected, updated and upgraded by Pascal Paquay */

#include <LiquidCrystal.h>
#include <Wire.h>
#include <EEPROM.h>
#include <Keypad.h>
LiquidCrystal lcd(1, 2, 4, 5, 6, 7); /* set the LCD address to 0x27 for a 16 chars and 2 line display. 
any other display can be used,just change parameters. */
int numberOfPedal = 8; /*adapt this number to your needs = number of loop pedals */
const byte rows = 8; /*number of switches variable */
const byte cols = 3; /*the three mode of selector*/
char keys[rows][cols] = {
{'a','i','q'},
{'b','j','r'},
{'c','k','s'},
{'d','l','t'},
{'e','m','u'},
{'f','n','v'},
{'g','o','w'},
{'h','p','x'} /* {'y','z','0'}, {'1','2','3'}, {'*','%','!'} add more characters if needed */
};

byte rowPins[rows] = {22, 23, 24,25, 26,27, 28, 29}; /*switch pins 1 to 8 */
byte colPins[cols] = {30, 31, 32}; /*selector pins a to h/ i to p/ q to x */
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);
int relayPin[8] = {33,34,35,36,37,38,39,40};
int ledPin[8] = {41,42,43,44,45,46,47,48};
byte midiChannel = 0;
int i;
int readOut;


/******************************************************/

void setup()
{
  for(i=0; i<numberOfPedal; i++)
   {
    pinMode(relayPin[i], OUTPUT);
    pinMode(ledPin[i], OUTPUT);
    digitalWrite(relayPin[i],HIGH); //pullup all relay outputs in case off low level relayboard
   }
Serial.begin(31250); /* for midi communication - pin 1 TX */
/*for (int i = 0; i < 512; i++) // erase eeprom (optional)
// EEPROM.write(i, 0); */
lcd.begin (16,2); // for 16 x 2 LCD module

lcd.print("Stompbox looper");
lcd.setCursor(0,1);
lcd.print("Pascal & CarraN");
delay(200);
}

/*********************************************************/

void midiProg(byte status, int data)
{
Serial.write(status);
Serial.write(data);
}

/*********************************************************/

void memory(int addr, int led)
{
  for(i=0; i<numberOfPedal; i++)
    {
      EEPROM.write((addr) + i, digitalRead(relayPin[i]));
      digitalWrite(ledPin[i], LOW);
    }
lcd.clear();lcd.print("Stored at ");
lcd.print(led + 1);
delay(100);
digitalWrite(ledPin[led], HIGH);
delay(100);
digitalWrite(ledPin[led], LOW);
delay(100);
digitalWrite(ledPin[led], HIGH);
delay(100);
digitalWrite(ledPin[led], LOW);
delay(100);
digitalWrite(ledPin[led], HIGH);
delay(100);
digitalWrite(ledPin[led], LOW);
delay(100);
digitalWrite(ledPin[led], HIGH);
lcd.clear();
}

/*********************************************************/

void writeOut(int relay)
{
  digitalWrite(relayPin[relay], !digitalRead(relayPin[relay]));
  digitalWrite(ledPin[relay], !digitalRead(relayPin[relay]));
  lcd.clear();
  lcd.print(" loop FX ");
  lcd.print(relay + 1);
}

/*********************************************************/

void readPreset(int addr, int pcNum, int led)
{
  for(i=0; i<numberOfPedal; i++)
  {
    digitalWrite(relayPin[i], EEPROM.read((addr)+i));
    digitalWrite(ledPin[i], LOW);
    digitalWrite(ledPin[led], HIGH);
   }
   lcd.clear();
   lcd.print(" Preset ");
   lcd.print(led + 1);
   midiProg(0xC0, pcNum +1); /* send midi change program 1 */
}

/******************************************************/

void loop()
{
char key = keypad.getKey();
if(key) // Check for a valid key.
  {
   switch (key)
    {
     case 'a': /* 'a' to 'h' for 8 pedals- adapt it to the number you needs */
      writeOut(0);
      break;
     case 'b':
      writeOut(1); /* (relay number,led number) */
      break;
     case 'c':
      writeOut(2);
      break;
     case 'd':
      writeOut(3);
      break;
     case 'e':
      writeOut(4);
      break;
     case 'f':
      writeOut(5);
      break;
     case 'g':
      writeOut(6);
      break;
     case 'h':
      writeOut(7);
      break;
/****************************** STORE PRESET MODE */
     case 'i': /* same remark as previous */
      memory(11,0);
      break;
     case 'j':
      memory(21,1); /* (EEPROM address, led) */
      break;
     case 'k':
      memory(31,2);
      break;
     case 'l':
      memory(41,3);
      break;
     case 'm':
      memory(51,4);
      break;
     case 'n':
      memory(61,5);
      break;
     case 'o':
      memory(71,6);
      break;
     case 'p':
      memory(81,7);
      break;
/****************************** READ PRESET MODE (EEProm address,PcNum,led number)*/
     case 'q':
      readPreset(11, 1, 0); 
      break;
     case 'r':
      readPreset(21, 2, 1);
      break;
     case 's':
      readPreset(31, 3, 2);
      break;
     case 't':
      readPreset(41, 4, 3);
      break;
     case 'u':
      readPreset(51, 5, 4);
      break;
     case 'v':
      readPreset(61, 6, 5);
      break;
     case 'w':
      readPreset(71, 7, 6);
      break;
     case 'x':
      readPreset(81, 8, 7);
      break;
      }
    }
}

Regards

Kaborex

It also appears that whenever I press the upload to arduino button the display changes. see attached pictures.

Regards

Kaborex

Quick update.

I managed to figure this one out. I deleted the following lines in the original code and the display works as intended. I must point out I do not know how this will affect the program when all is connected together finally, Bbut I have no need for the mid part in any case.

Serial.begin(31250); /* for midi communication - pin 1 TX */
/*for (int i = 0; i < 512; i++) // erase eeprom (optional)
// EEPROM.write(i, 0); */

Solved my first mystery. Thanks to Bill of course. Very knowledgable man in this field.

Much appreciated.

Regards

Kaborex

Hi Bill,

I t would be interesting to have your views on why the lines I deleted where affecting the LCD. Just curious as this is all new to me.

Regards

Kaborex

I would recommend not using Arduino pin 1 for the LCD.
Pins 0 and 1 are used by the serial port.
Using pin 1 for the LCD creates a pin conflict.