Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to display message on 16*2 LCD in my native language Hindi

Status
Not open for further replies.

Djsarkar

Member
I want to display message in my native language Hindi. I want to display सरकार on LCD

any idea how to do ?

PIC18F45K80, MPLABX xc8

C:
//
#define _XTAL_FREQ 20000000     // crystal 20MHz

// PIC18F45K80 Configuration Bit Settings
// CONFIG1L
#pragma config RETEN = ON       // VREG Sleep Enable bit (Ultra low-power regulator is Enabled (Controlled by SRETEN bit))
#pragma config INTOSCSEL = LOW  // LF-INTOSC Low-power Enable bit (LF-INTOSC in Low-power mode during Sleep)
// SOSCSEL = No Setting
#pragma config XINST = OFF      // Extended Instruction Set (Disabled)
// CONFIG1H
#pragma config FOSC = HS2       // HS oscillator (high power, 16 MHz-25 MHz
#pragma config PLLCFG = OFF     // PLL x4 Enable bit (Disabled)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor (Disabled)
#pragma config IESO = OFF       // Internal External Oscillator Switch Over Mode (Disabled)
// CONFIG2L
#pragma config PWRTEN = ON      // Power Up Timer (Enabled)
#pragma config BOREN = OFF      // Brown Out Detect (Disabled in hardware, SBOREN disabled)
#pragma config BORV = 0         // Brown-out Reset Voltage bits (3.0V)
#pragma config BORPWR = LOW     // BORMV Power level (BORMV set to low power level)
// CONFIG2H
#pragma config WDTEN = OFF      // Watchdog Timer (WDT disabled in hardware; SWDTEN bit disabled)
#pragma config WDTPS = 1        // Watchdog Postscaler (1:1)
// CONFIG3H
#pragma config CANMX = PORTC    // ECAN Mux bit (ECAN TX and RX pins are located on RC6 and RC7, respectively)
#pragma config MSSPMSK = MSK5   // MSSP address masking (5 bit address masking mode)
#pragma config MCLRE = ON      // Master Clear Enable (MCLR Enabled, RE3 Disabled)
// CONFIG4L
#pragma config STVREN = OFF     // Stack Overflow Reset (Disabled)
#pragma config BBSIZ = BB1K     // Boot Block Size (1K word Boot Block size)
// CONFIG5L
#pragma config CP0 = ON         // Code Protect 00800-01FFF (Enabled)
#pragma config CP1 = ON         // Code Protect 02000-03FFF (Enabled)
#pragma config CP2 = ON         // Code Protect 04000-05FFF (Enabled)
#pragma config CP3 = ON         // Code Protect 06000-07FFF (Enabled)
// CONFIG5H
#pragma config CPB = ON         // Code Protect Boot (Enabled)
#pragma config CPD = ON         // Data EE Read Protect (Enabled)
// CONFIG6L
#pragma config WRT0 = ON        // Table Write Protect 00800-01FFF (Enabled)
#pragma config WRT1 = ON        // Table Write Protect 02000-03FFF (Enabled)
#pragma config WRT2 = ON        // Table Write Protect 04000-05FFF (Enabled)
#pragma config WRT3 = ON        // Table Write Protect 06000-07FFF (Enabled)
// CONFIG6H
#pragma config WRTC = ON        // Config. Write Protect (Enabled)
#pragma config WRTB = ON        // Table Write Protect Boot (Enabled)
#pragma config WRTD = ON        // Data EE Write Protect (Enabled)
// CONFIG7L
#pragma config EBTR0 = ON       // Table Read Protect 00800-01FFF (Enabled)
#pragma config EBTR1 = ON       // Table Read Protect 02000-03FFF (Enabled)
#pragma config EBTR2 = ON       // Table Read Protect 04000-05FFF (Enabled)
#pragma config EBTR3 = ON       // Table Read Protect 06000-07FFF (Enabled)
// CONFIG7H
#pragma config EBTRB = ON       // Table Read Protect Boot (Enabled)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#pragma warning disable 520

#include <xc.h>

#define RS            LATBbits.LATB4
#define RW            LATBbits.LATB5
#define EN            LATBbits.LATB6

#define LCD_Port      LATD

//Port Initialized
void Port_Initialized (void)
{
// LATx registers
    LATA =  0x00;
    LATB =  0x00;
    LATC =  0x00;
    LATD =  0x00;
    LATE =  0x00;

//  TRISx registers
    TRISA = 0x00;     // All are output, Unused
    TRISB = 0x00;     // RS, R/W EN
    TRISC = 0x00;     //all are output, Unused
    TRISD = 0x00;     // LCD Port
    TRISE = 0x00;     // All are output, Unused

    ANCON0 = 0x00;    // digital port
    ANCON1 = 0x00;    // Set to digital port
    CM1CON = 0x00;    // Comparator off
    CM2CON = 0x00;    // Comparator off
    ADCON0 = 0x00;    // A/D conversion Disabled
    ADCON1 = 0x00;    // A/D conversion Disabled
    ADCON2 = 0x00;    // A/D conversion Disabled
}
void Enable_Pulse()
{
    EN = 1;
    NOP();   //200ns ;
    EN = 0;
    NOP();   //200ns ;
}
//Send only high nibble to the LCD
void WriteNibble(unsigned char command)
{
    RS = 0; RW = 0; // Make RS, RW low to write command 
    NOP();   //200ns
    LCD_Port = command & 0xF0 ;  // Send only four upper nibble
    Enable_Pulse();
}

//Send a high nibble and low nibble to the LCD
void LCD_WriteCommand(unsigned char command)
{
   //
    RS = 0; RW = 0;
    NOP();// 200ns
  
    LCD_Port = command & 0xF0 ;             // Send only high nibble
    Enable_Pulse();
  
    LCD_Port =  ((command << 4) & 0xF0);   // Send low nibble
    Enable_Pulse();
  
    __delay_us(50);                        // wait more then 37us
}

//Initialized  LCD
void  LCD_Initialized()
{
    __delay_ms(15);          // Wait more than 15 ms
    WriteNibble(0x30);       // Function set
    __delay_ms(5);           // Wait more than 4.1 ms
    WriteNibble(0x30);       // Function set
    __delay_us(100);         // Wait for more than 100 ?s
    WriteNibble(0x30);       // Function set
    __delay_ms(1);   
    LCD_WriteCommand(0x20);  // set to 4 bit interface
    LCD_WriteCommand(0x2C);  // set to 4 bit interface, 2 line and 5*10 font
    LCD_WriteCommand(0x06);  // move cursor right after write
    LCD_WriteCommand(0x0C);  // Display On 
    LCD_WriteCommand(0x01);  // clear display
    __delay_ms(3);
}

// Send Data to LCD
void LCD_WriteData(unsigned char Byte)
{
    RS = 1; RW = 0 ;                        // Make RS high and RW low to write data   
    NOP(); 
    LCD_Port = Byte & 0xF0 ;                // send high nibble
    Enable_Pulse();
    LCD_Port = (unsigned char)(Byte << 4 );  // send low nibble
    Enable_Pulse(); 
   __delay_us(40);                           // wait more then 37us
}

//Send a character to the LCD
void LCD_Data( unsigned char *S)
{
    while (*S != '\0')
    {
      LCD_WriteData(*S);
      __delay_ms(1); //// wait more 1ms
        S++;
    }
}


void main ()
{
    unsigned char String []={"Please help"};
  
    Port_Initialized (); //Port Initialized
    LCD_Initialized();   //Initialized  LCD
    LCD_Data(String);    // Send a string to LCD
  
    while (1);
}
 
The trouble with these characters, they don't display well

1624646502241.png
 
You can only display 8 (different) characters. You may need to switch to a pixel based display. Plus, may need higher resolution.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top