16x2 display blue back light problem with white light

Hi everyone this is my lcd driver code, ı can read the output but the ouput is black and silly light on blue cover. normally it has to be in white light and strong. Where is my fault ? Thank you.

// lcd.c file
#include <stdio.h>
#include <stdarg.h>

#include "io.h"
#include "system.h"
#include "lcd.h"

// Paralel 4-bit haberle�me ile bir ad�m (4-bit)
// veri g�nderir. Veri komut ya da karakter kodu olabilir
// G�nderilecek de�er: Parametrenin low 4-biti
static void LCD_SendDataL(unsigned char c)
{
  // Senkron 4-bit paralel haberle�me
  
  // 1) Data setup (verinin haz�rlanmas�)
  IO_Write(IOP_LCD_DB4, (c & 1) != 0);
  IO_Write(IOP_LCD_DB5, (c & 2) != 0);
  IO_Write(IOP_LCD_DB6, (c & 4) != 0);
  IO_Write(IOP_LCD_DB7, (c & 8) != 0);
  // Data setup hold time
  // DelayUs(1);
  
  // 2) Clock generation (verinin onaylanmas�)
  IO_Write(IOP_LCD_E, 1);
  DelayUs(1);   // Clock high time
  IO_Write(IOP_LCD_E, 0);
  
  DelayUs(100);   // Clock low time + process time  
}

static void LCD_SendCmdL(unsigned char c)
{
  IO_Write(IOP_LCD_RS, 0);      // Komut modu
  
  LCD_SendDataL(c);
}

// LCD mod�le 8-bit veri g�nderir
static void LCD_SendData(unsigned char c)
{
  LCD_SendDataL(c >> 4);        // high 4-bit
  LCD_SendDataL(c);             // low 4-bit
}

// LCD mod�le 8-bit komut g�nderir
void LCD_SendCmd(unsigned char c)
{
  IO_Write(IOP_LCD_RS, 0);      // Komut modu
  
  LCD_SendData(c);             // 8-bit data
  
  DelayUs(40);
}

void LCD_ClearDisplay(void)
{
  LCD_SendCmd(0x01);
  
  DelayMs(2);
}

void LCD_Control(unsigned char ctl)
{
  ctl &= 7;     // 0000 0111
  
  LCD_SendCmd(0x08 | ctl);
}

// LCD mod�le 8-bit karakter kodu g�nderir
void LCD_PutChar(unsigned char c)
{
  IO_Write(IOP_LCD_RS, 1);      // Komut modu
  
  LCD_SendData(c);             // 8-bit data
}

void LCD_Shift(unsigned char rl)
{
  rl &= 1;      // 0000 0001
  LCD_SendCmd(0x18 | (rl << 2));
}

void LCD_SetCursor(unsigned char pos)
{
  pos &= 0x7F;
  LCD_SendCmd(0x80 | pos);
}

// LCD mod�l� 4-bit ara y�z ve di�er uygun
// parametrelerle ba�lat�r
void LCD_Init(void)
{
  // STM32 i�in gerekmiyor ��nk� ODR'ler default 0
  IO_Write(IOP_LCD_RS, 0);
  IO_Write(IOP_LCD_E, 0);
  IO_Write(IOP_LCD_DB4, 0);
  IO_Write(IOP_LCD_DB5, 0);
  IO_Write(IOP_LCD_DB6, 0);
  IO_Write(IOP_LCD_DB7, 0);

  IO_Init(IOP_LCD_RS, IO_MODE_OUTPUT);
  IO_Init(IOP_LCD_E, IO_MODE_OUTPUT);
  IO_Init(IOP_LCD_DB4, IO_MODE_OUTPUT);
  IO_Init(IOP_LCD_DB5, IO_MODE_OUTPUT);
  IO_Init(IOP_LCD_DB6, IO_MODE_OUTPUT);
  IO_Init(IOP_LCD_DB7, IO_MODE_OUTPUT);
  
  DelayMs(40);
  
  LCD_SendCmdL(0x03);
  DelayMs(5);
  LCD_SendCmdL(0x03);
  DelayUs(60);

  LCD_SendCmd(0x32);
  LCD_SendCmd(0x28);    // N=1 F=0 (�ok sat�r, k���k font)
  
  //LCD_SendCmd(0x08);    // Display on/off controll (display off)
  LCD_Control(LCD_DISPLAY_OFF);
  
  //LCD_SendCmd(0x01);    // Display clear
  LCD_ClearDisplay();
  
  LCD_SendCmd(0x06);

  LCD_Control(LCD_DISPLAY_ON);
}  

///////////////////////////////////////////////////

void LCD_putch(unsigned char c)
{
  switch (c) {
  case '\r': 
    LCD_SetCursor(0);
    break;
    
  case '\n':
    LCD_SetCursor(0x40);
    break;
    
  case '\f': 
    LCD_ClearDisplay();
    break;
    
  default:
    LCD_PutChar(c);
    break;
  }
}

int LCD_puts(const char *str)
{
  int i = 0;
  
  while (str[i])
    LCD_putch(str[i++]);
  
  return i;
}

int LCD_printf(const char *fmt, ...)
{
  int size;
  
  va_list args;
  static char str[256];
  
  va_start(args, fmt);
  vsnprintf(str, 256, fmt, args);
  
  size = LCD_puts(str);
  
  return size;
}

Hi, @engr_fatihuruc

Have you adjusted the contrast potentiometer?
Have you had this LCD performing properly, or is it the first time using it?

What characters are you displaying?
Have you tried the example code that comes with the lcd.h library?
What model Arduino are you using?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

1 Like

Hey Tom thanks for answering, @TomGeorge

Yes I have arranged my pot. And Also I have made this lcd display work on ESP32 properly with Ardunio IDE libs. Now I am using Stm32f103c8 in c language. I am just testing my lcd so I make counted some number on lcd and some texts etc. I wrote this driver in 4 bit. Honestly this is the first experience in c lang so thought I have missed somethings :slight_smile:

Your topic has been moved to a more suitable location on the forum. See the sticky topics in Uncategorized - Arduino Forum why you should not have posted where you posted :wink:

1 Like

Invest in an I²C module for the LCD, it saves time and nerves.

1 Like

Is "A" connected to Vcc through a resistor (200ohm - 500ohm)? Is it needed?

Where is void setup(); and void loop();

Maybe the printing and lcd clear is to fast.

...

Look like the pots green wire is not connected to GND , need a jumper to connect the 2 long strips or move the green wire to the GND strip.

Hi, @engr_fatihuruc

Is it compatible with the library you are using?

Can you please post a link to the library source?

Thanks.. Tom... :grinning: :+1: :australia:

In suspect that OP is writing his/her own library. I might be wrong though.

1 Like

This is normal for the human intelligence. :smile:

1 Like

I agree with this. They make life easier. $2 each

https://www.amazon.com/Anmbest-Interface-LCD1602-Backlight-Expansion/dp/B07RPW7WLB?ref=silk_bia

Of course, you are definitely right but this is a challenge ı need to complete :slight_smile: at the other projects ı am using this module.

I have connected as you referred but result is same :frowning:

@TomGeorge this is the library ı have created, but if you would like I can share the files with header files :slight_smile:

I have realized that at lcd display with only black white lights, it does work properly.

Remove the power and press and hold the Reset button on the STM32F while pressing the Reset button put the power back keep pressing the button.

The LCD should light up with one top row of white blocks , adjust the pot.

First get the white blocks then continue with the rest of the code.

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