16 x 2 LCD not displaying text

Hi guys,

I want to display the speed and direction of a stepper motor.

I have 16 x 2 LCD display (Data sheet and connection diagram attached. The LCD has a ST7066 driver.

I tried my code and also the hello world example from the arduino IDE (with potentiometer) but no luck. By adjusting the contrast I can only see white boxes but no text.l

I would highly appreciate if you guys can help me.

Regards,

#include <LiquidCrystal.h>

#include <AccelStepper.h>

LiquidCrystal lcd(11,10,9,8,A4,A5);

AccelStepper stepper1(1, 13, 12);

const int STOP_PIN = 4;      // ON/OFF switch
const int RIGHT_PIN = 2;     // direction switch
const int ledPin_1 = 7;      // right direction LED
const int ledPin_2 = 5;      // left direction LED
const int ledPin_3 = 6;      // ON/OFF LED pin

#define  MAX_SPEED 800
#define  MIN_SPEED 0.1

int SPEED_PIN = 2;    //input pin for the potentiometer

void setup() {

lcd.begin(16, 2);
lcd.home();

lcd.print("TEST");

stepper1.setMaxSpeed(10000.0);
pinMode(ledPin_1, OUTPUT);
pinMode(ledPin_2, OUTPUT);
pinMode(ledPin_3, OUTPUT);
pinMode(STOP_PIN, INPUT);
pinMode(RIGHT_PIN, INPUT);

digitalWrite (ledPin_1, LOW);
digitalWrite (ledPin_2, LOW);
digitalWrite (ledPin_3, LOW);
  
Serial.begin(9600);
}

void loop() {
  static float current_speed = 0.0;         // Holds current motor speed in steps/second
  static int analog_read_counter = 1000;    // Counts down to 0 to fire analog read
  static char sign = 0;                     // Holds -1, 1 or 0 to turn the motor on/off and control direction
  static int analog_value = 0;              // Holds raw analog value.
  
  
  if (digitalRead(STOP_PIN) == 0) {
    sign = 0;
    digitalWrite (ledPin_1, LOW);
    digitalWrite (ledPin_2, LOW);
    digitalWrite (ledPin_3, HIGH);
    
  }
  else if (digitalRead(RIGHT_PIN) == 1) {
    sign = 1;
    digitalWrite (ledPin_1, HIGH);
    digitalWrite (ledPin_2, LOW);
    digitalWrite (ledPin_3, LOW);
  }
  else if (digitalRead(RIGHT_PIN) == 0) {    
    sign = -1;
    digitalWrite (ledPin_1, LOW);
    digitalWrite (ledPin_2, HIGH);
    digitalWrite (ledPin_3, LOW);
    
  }
  

  // We only want to read the pot every so often (because it takes a long time we don't
  // want to do it every time through the main loop).  
  if (analog_read_counter > 0) {
    analog_read_counter--;
  }
  else {
    analog_read_counter = 3000;
    // Now read the pot (from 0 to 1023)
    analog_value = analogRead(SPEED_PIN);
    // Give the stepper a chance to step if it needs to
    stepper1.runSpeed();
    //  And scale the pot's value from min to max speeds
    current_speed = sign * ((analog_value/1023.0) * (MAX_SPEED - MIN_SPEED)) + MIN_SPEED;
    // Update the stepper to run at this new speed
    stepper1.setSpeed(current_speed);
  }

  // This will run the stepper at a constant speed
  stepper1.runSpeed();
}

ADM1602K-NSW-FBS-3.3v.pdf (897 KB)

I tried my code and also the hello world example from the arduino IDE (with potentiometer) but no luck. By adjusting the contrast I can only see white boxes but no text.

It is unclear whether you removed all the stepper motor related code when you ran the 'Hello World' example. When you are having trouble verifying that a display works you should use the simplest code possible and avoid doing anything in loop() until you can display something in setup().

Try something like this:

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);      // put your pin numbers here

void setup()
 {
 lcd.begin(16, 2);                          // put your LCD parameters here
 lcd.print("hello, world!");
 lcd.setCursor(0,1);
 lcd.print("it works!");
 }

void loop()
 {
                                            // do nothing in 'loop'
 }

Don

Hi Don,

Thanks for your reply.

I tried the hello world example without the stepper code.

I also tried your code but same problem. I only see blocks in the top line without potentiometer. But if I use the potentiometer the blocks become darker and appera on both lines but still no text.

Regards,

As you are seeing the row of blocks it is unlikely that your display is defective. Since the code is valid that leaves your connections as the probable culprit.

The best way to resolve this is for you to post a photograph or two that allows us to examine your soldering job and also allows us to unambiguously follow each wire from the LCD to the Arduino.

You should also check the continuity of your jumper wires, especially if they originated in the far east.

Don

Try removing the potentiometer and simply connecting contrast to ground. I don't use a potentiometer I just connect contrast to ground.

budrow01: Try removing the potentiometer and simply connecting contrast to ground. I don't use a potentiometer I just connect contrast to ground.

Connecting LCD pin 3 to GND will frequently give an acceptable display and that is a good troubleshooting technique to use when the display is blank.

In his case his display is not blank. He is able to adjust the potentiometer to see a row of blocks so his problem has nothing to do with the contrast adjustment.

Don