1. 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.
    Dismiss Notice

how to display letters in program

Discussion in 'Microcontrollers' started by Parth86, Sep 9, 2017.

  1. Parth86

    Parth86 Member

    Joined:
    Dec 25, 2011
    Messages:
    513
    Likes:
    5
    How to display letters in embedded c programming? 8051 and keil compiler
    For Example
    /* Display "E" at 2nd column in first row */
    /* Display "T" at 3rd column in first row */
    /* Display "0" at 3rd column in second row */
    Code (c):

        #include<reg51.h>
        /* Data pins connected to port P1 of 8051 */
        #define  Data_Port_Pins                            (P1)
        sbit    Register_Select_Pin   = P2^0;           /* Register Pin of LCD connected to Pin 0 of Port P2 */
        sbit    Read_Write_Pin        = P2^1;           /* Read/Write Pin of LCD connected to Pin 1 of Port P2 */
        sbit    Enable_Pin            = P2^2;           /* EN pin connected to pin 2 of port P2 */
        /* Function for creating delay in milliseconds */
        void Delay(unsigned int wait)
           {
              unsigned i, j;
              for(i = 0; i < wait; i++)
                 for(j = 0; j < 1200; j++);
           }
       
        /* Function to send command instruction to LCD */
        void LCD_Command (unsigned char command)
        {
            Data_Port_Pins = command;
            Register_Select_Pin =0;
            Read_Write_Pin=0;
            Enable_Pin =1;
            Delay (2);
            Enable_Pin =0;
        }
        /* Function to send display data to LCD */
        void LCD_Data (unsigned char Data)
        {
            Data_Port_Pins = Data;
            Register_Select_Pin=1;
            Read_Write_Pin=0;
            Enable_Pin =1;
            Delay(2);
            Enable_Pin =0;
        }
        /* Function to prepare the LCD  and get it ready */
        void LCD_Initialization()
        {
            LCD_Command (0x38);
            LCD_Command (0x0e);
            LCD_Command (0x01);
            LCD_Command (0x81);
        }
           void main()
    {
      /* Display "E" at 2nd column in first row */
     /* Display "T" at 3rd column in first row */
    /* Display "T" at 3rd column in second row */
    }
     
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,160
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE
    Write a LCD goto function... If you send 0x80 to the LCD the cursor will be at the start position.. If you send 0x80 plus 0x40 (0xCo) you will be at the beginning of the second row... So then add in the columns.
    Code (c):

    void LCD_goto( char x, char y)
       {
       int addr = 0x80;   // start address
       if(y==2) addr+=0x40;  // are we on second row
       addr += x;    // add in the columns
       LCD_command(addr);   // send to display.
       }
     
     
  3. Parth86

    Parth86 Member

    Joined:
    Dec 25, 2011
    Messages:
    513
    Likes:
    5
    sorry but I didn't understand that function. In my opinion It should be like this
    Code (c):
     main ()
    {
    LCD_Initialization();
    while (1)
        {
           LCD_Position(row, pos);
           LCD_Data('E');        /* Display "E" at 1nd column in first row */
           LCD_Position(row, pos);
           LCD_Data('T');        /* Display 'T' at 2nd column in first row */
         }
    }
     
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,160
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE

    Write what you want... Call it what you want... It'll still be the sane function..
     

Share This Page