4-Bit LCD Programming Help

Hello,

I’m currently trying to interface an LCD (Winstar WH2004A) with an Arduino Blend board and simply display my name and the date. It is part of a college project where I can’t use any libraries so can’t use the liquid crystal one as i’ve done previously.

I’ve attempted it and believe I’ve initialised the LCD screen correctly but when the comes to displaying the first character which should be ‘M’ I seen to just get ‘O’. Possibly believe this is due to a programming error where the Lower 4-Bit nibble is being looked at. Program attached.

Any pointers would be much appriciated :slight_smile:

Martyn.

_4-bit-mwtrial.ino (3.15 KB)

You are likely to get more members willing to help if you post your code as described in the stickies. Downloading code is a pain in the --s.

Please post your code here to make it more easily accessible making sure to use code tags as described in read this before posting a programming question

int LCD_D7 = 7  ; 
int LCD_D6 = 6  ;
int LCD_D5 = 5  ;
int LCD_D4 = 4  ;
int LCD_E = 9   ;
int LCD_RS = 8;

#define lcd_LineOne   0x00;
#define lcd_LineTwo   0x40;

void setup() {

  pinMode(LCD_D7, OUTPUT) ;
  pinMode(LCD_D6, OUTPUT) ;
  pinMode(LCD_D5, OUTPUT) ;
  pinMode(LCD_D4, OUTPUT) ;
  pinMode(LCD_E,  OUTPUT) ;
  pinMode(LCD_RS, OUTPUT) ;

  delay (45) ;
  // Initial Function Set (1)
  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_E, LOW);
  digitalWrite (LCD_D7, LOW);
  digitalWrite (LCD_D6, LOW);
  digitalWrite (LCD_D5, HIGH);
  digitalWrite (LCD_D4, HIGH);

  delay (1) ;
  // Initial Function Set (2)
  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_D7, LOW);
  digitalWrite (LCD_D6, LOW);
  digitalWrite (LCD_D5, HIGH);
  digitalWrite (LCD_D4, HIGH);

  delay (1) ;
  // Initial Function Set (3)
  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_D7, LOW);
  digitalWrite (LCD_D6, LOW);
  digitalWrite (LCD_D5, HIGH);
  digitalWrite (LCD_D4, HIGH);

  delay (1);
  // Function Set
  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_D7, LOW);
  digitalWrite (LCD_D6, LOW);
  digitalWrite (LCD_D5, HIGH);
  digitalWrite (LCD_D4, LOW); // 4-bit

  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_D7, HIGH); // N
  digitalWrite (LCD_D6, LOW); // F

  delay (1);
  //Display On/Off Control
  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_D7, LOW);
  digitalWrite (LCD_D6, LOW);
  digitalWrite (LCD_D5, LOW);
  digitalWrite (LCD_D4, LOW);

  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_D7, HIGH);
  digitalWrite (LCD_D6, LOW); //D
  digitalWrite (LCD_D5, LOW); //C
  digitalWrite (LCD_D4, LOW); //B

  delay (1);
  // Display Clear
  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_D7, LOW);
  digitalWrite (LCD_D6, LOW);
  digitalWrite (LCD_D5, LOW);
  digitalWrite (LCD_D4, LOW);

  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_D7, LOW);
  digitalWrite (LCD_D6, LOW);
  digitalWrite (LCD_D5, LOW);
  digitalWrite (LCD_D4, HIGH);

  delay (2);
  // Enter Mode Set
  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_D7, LOW);
  digitalWrite (LCD_D6, LOW);
  digitalWrite (LCD_D5, LOW);
  digitalWrite (LCD_D4, LOW);

  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_D7, LOW);
  digitalWrite (LCD_D6, HIGH);
  digitalWrite (LCD_D5, HIGH); // I/D
  digitalWrite (LCD_D4, LOW); // S
  delay (1);

  //Display On/Off Control
  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_D7, LOW);
  digitalWrite (LCD_D6, LOW);
  digitalWrite (LCD_D5, LOW);
  digitalWrite (LCD_D4, LOW);

  digitalWrite (LCD_RS, LOW);
  digitalWrite (LCD_D7, HIGH);
  digitalWrite (LCD_D6, HIGH); //D
  digitalWrite (LCD_D5, HIGH); //C
  digitalWrite (LCD_D4, HIGH); //B

  //-------------------------------------

  digitalWrite (LCD_RS, HIGH);
  delay (2000);

  //Function Set (Upper 4 Bit)
  digitalWrite (LCD_D4, LOW);
  digitalWrite (LCD_D5, LOW);
  digitalWrite (LCD_D6, HIGH);
  digitalWrite (LCD_D7, LOW);

  //Write Data to Display
  digitalWrite (LCD_E, HIGH);
  delay (50);
  digitalWrite (LCD_E, LOW);

  //Function Set (Lower 4 Bit)

  digitalWrite (LCD_D4, LOW);
  digitalWrite (LCD_D5, HIGH);
  digitalWrite (LCD_D6, HIGH);
  digitalWrite (LCD_D7, LOW);

  //Write Data to Display
  digitalWrite (LCD_E, HIGH);
  delay (50);
  digitalWrite (LCD_E, LOW);

  delay (2000);

}

void loop() {
}