{"id":20956912,"url":"https://github.com/gmostofabd/8051-lcd","last_synced_at":"2026-05-22T10:16:42.654Z","repository":{"id":152405354,"uuid":"369994713","full_name":"gmostofabd/8051-LCD","owner":"gmostofabd","description":"📚 This repository demonstrates how to interface a 16x2 alphanumeric LCD with the 8051 Microcontrollers (AT89S52) using Assembly Language Programming. The project is designed to showcase a practical example of sending data from the 8051 microcontroller to an LCD and includes Proteus simulation files for testing, modify, debug and visualization.","archived":false,"fork":false,"pushed_at":"2024-09-25T17:21:05.000Z","size":1109,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T23:44:14.373Z","etag":null,"topics":["4bit","8051","8bit","assembly","circuit","code","download","experiment","hex","interfacing","language","lcd","microcontroller","mode","programming","proteus","simulation"],"latest_commit_sha":null,"homepage":"https://gmostofabd.github.io/8051-LCD/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gmostofabd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-23T08:03:39.000Z","updated_at":"2024-12-28T18:56:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"a2e6704c-ee8c-416a-8c48-a3c4bbe282f4","html_url":"https://github.com/gmostofabd/8051-LCD","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmostofabd%2F8051-LCD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmostofabd%2F8051-LCD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmostofabd%2F8051-LCD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmostofabd%2F8051-LCD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gmostofabd","download_url":"https://codeload.github.com/gmostofabd/8051-LCD/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243352033,"owners_count":20276916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["4bit","8051","8bit","assembly","circuit","code","download","experiment","hex","interfacing","language","lcd","microcontroller","mode","programming","proteus","simulation"],"created_at":"2024-11-19T01:28:34.102Z","updated_at":"2025-12-27T13:19:37.623Z","avatar_url":"https://github.com/gmostofabd.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚙️ **LCD Interfacing with 8051 Microcontroller**\n\nThis repository demonstrates interfacing a **16x2 alphanumeric LCD** with the **8051 Microcontroller** using **Assembly language**. The project is designed to show how to send data from the **8051 microcontroller** to an LCD. It includes **Proteus simulation files** for testing and visualization.\n\n\u003cdiv style=\"border: 2px solid #4CAF50; border-radius: 10px; padding: 20px; text-align: center; background-color: #f9f9f9; margin: 20px auto; width: 80%;\"\u003e\n\n  \u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/gmostofabd/8051-LCD/blob/82e89081c795286c466389d6ac5c34e6ec4a8050/assets/images/LCD_8B_8051_Ckt.png\" alt=\"8051 Microcontroller LCD Interface\" width=\"80%\"\u003e\n    \u003cbr\u003e\n    \u003cb style=\"font-size: 1.5em;\"\u003eFig-1:\u003c/b\u003e 8051 Microcontroller LCD Interface (Schematic Diagram).\n  \u003c/p\u003e\n  \n  \u003cp style=\"font-size: 1em; color: #555;\"\u003eThe figure above shows the circuit schematic for interfacing the **16x2 LCD** with the **AT89C51 Microcontroller**. It includes essential connections for data transfer, control, and power, enabling the display of alphanumeric characters using **8-bit data mode**.\u003c/p\u003e\n\n\u003c/div\u003e\n\n---\n\n## 🔑 **Keywords**\n\n[**AT89C51 Microcontroller**](https://en.wikipedia.org/wiki/Intel_MCS-51) | [**Assembly Language**](https://en.wikipedia.org/wiki/Assembly_language) | [**Proteus**](https://www.labcenter.com/) | [**16x2 LCD**](https://en.wikipedia.org/wiki/Liquid-crystal_display) | [**LCD Interfacing**](https://en.wikipedia.org/wiki/Liquid-crystal_display)\n\n---\n\n## ⚙️ **Project Overview**\n\nThis project demonstrates **LCD interfacing** with the **[AT89C51 Microcontroller](https://www.atmel.com/products/microcontrollers/8051.aspx)**. It is useful for educational purposes and embedded systems applications, allowing the microcontroller to display data on the LCD.\n\n---\n\n## 🔧 **Key Features**\n\n\u003cdiv align=\"center\"\u003e\n\n| Feature                      | Description                                                                 |\n|-------------------------------|-----------------------------------------------------------------------------|\n| 📟 **LCD Display**             | Displays data entered or processed by the microcontroller                   |\n| 🖥️ **Proteus Simulation**      | Includes a ready-to-use simulation circuit compatible with Proteus 8.9      |\n| 💾 **Assembly Programming**    | Optimized assembly code for efficient execution on the AT89C51              |\n| 🛠️ **Real Hardware Test**      | Successfully tested on actual hardware for reliable performance             |\n\n\u003c/div\u003e\n\n---\n\n## 📦 **What’s Included?**\n\n\u003cdiv align=\"center\"\u003e\n\n| **File**               | **Description**                                                         |\n|------------------------|-------------------------------------------------------------------------|\n| **Assembly Code**       | The core assembly code for initializing and operating the LCD. (`exampleproject.asm`) |\n| **Proteus Simulation**  | Simulation file for testing the LCD interface in Proteus. (`exampleproject.pdsjr`)  |\n| **HEX File**            | Compiled HEX file for uploading to the 8051 microcontroller. (`exampleproject.hex`)   |\n| **Test Run Image**      | Image showing the test run result.                                      |\n\n\u003c/div\u003e\n\n---\n\n## 🖥️ **Installation \u0026 Usage**\n\n### Step-by-Step Guide:\n\n1. **Clone this repository**:\n   ```bash\n   git clone https://github.com/gmostofabd/8051-LCD.git\n   ```\n\n2. **Compile the Assembly Code**:\n   Open the `AT89C51_LCD_Keypad.asm` file in **MIDE-51** or any compatible IDE, and compile it to generate the **HEX file**.\n\n3. **Simulate in Proteus**:\n   Open **Proteus Design Suite**, load the provided simulation file, and run the simulation to observe the interface's functionality.\n\n4. **Program the Microcontroller**:\n   For real hardware, upload the **HEX file** to the AT89C51 microcontroller using a compatible programmer.\n\n5. **Test the Circuit**:\n   Assemble the hardware based on the provided circuit diagram, power it on, and verify the LCD's functionality.\n\n---\n\n## 🛠️ **Components Used**\n\n| **Component**              | **Description**                                                                                                                                  |\n|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| AT89C51 Microcontroller     | The core of the project, programmed in Assembly language to control the LCD.                                                                    |\n| 16x2 LCD                    | Displays the output of the microcontroller in alphanumeric form.                                                                                |\n| Crystal Oscillator (11.0592 MHz) | Provides a clock signal to the microcontroller for accurate timing.                                                                          |\n| 33pf Capacitors (2x)        | Used with the crystal oscillator to stabilize the clock signal, connected between XTAL1 and XTAL2 of the microcontroller and ground.             |\n| 100 Ohm Resistor            | Limits current in the circuit to protect components.                                                                                            |\n| 10K Variable Resistor (Potentiometer) | Adjusts the contrast of the LCD, wired between VCC and GND, with the wiper connected to the contrast pin (V0) of the LCD.                  |\n| Push-button Switch (Reset)  | Connected to the RST pin of the microcontroller for manual reset, with a pull-down resistor for stability.                                      |\n| Jumper Wires                | Connects components as needed.                                                                                                                 |\n\n---\n\n## 🌐 **LCD Display**\n\nA **Liquid Crystal Display (LCD)** provides a useful interface for embedded systems. The **16x2 LCD** displays textual information across two rows, each capable of showing 16 characters, with each character occupying a 5x7 matrix space on the screen.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/gmostofabd/8051-LCD/blob/82e89081c795286c466389d6ac5c34e6ec4a8050/assets/images/lcd_models.png\" alt=\"LCD Types\" width=\"70%\"\u003e\n\u003c/p\u003e\n\n---\n\n## 🌐 **16×2 LCD Pin Diagram**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/gmostofabd/8051-LCD/blob/82e89081c795286c466389d6ac5c34e6ec4a8050/assets/images/LCD_Pinout.png\" alt=\"LCD Pinout\" width=\"70%\"\u003e\n\u003c/p\u003e\n\n---\n\n## 🌐 **Programming LCD with 8051**\n\nTo interface with the **16x2 LCD**, follow these mandatory steps:\n\n1. **Initialization**:\n   - Set the LCD to 8-bit mode by sending initialization commands.\n\n2. **Set RS and RW Pins**:\n   - **RS**: Set to `0` for commands, `1` for data.\n   - **RW**: Set to `0` for writing, `1` for reading (not often used in basic setups).\n\n3. **Send Commands/Data**:\n   - Place the command or data in the data register and trigger the **Enable Pin**.\n\n4. **Enable Pulse**:\n   - Toggle the **Enable Pin** to send the command/data.\n\n5. **Delay**:\n   - Wait briefly after each command/data transfer to allow the LCD to process it.\n\n---\n\n### Assembly Code for 8-Bit Mode LCD Interfacing \n\n```assembly \n; -----------------------------\n; LCD Interfacing in 8-Bit Mode (lcd_8bit.asm)\n; -----------------------------\n\nORG 00H                  ; Set origin to address 00H\n\nMOV SP, #70H             ; Initialize stack pointer at address 70H\nMOV PSW, #00H            ; Set program status word to 00H\n\nLCD_IN: \n    MOV A, #38H          ; Initialize LCD for 2 lines, 5x7 matrix\n    LCALL COMNWRT        ; Call command write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #0EH          ; Display ON, Cursor ON\n    LCALL COMNWRT        ; Call command write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #01H          ; Clear LCD display\n    LCALL COMNWRT        ; Call command write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #06H          ; Shift cursor to the right\n    LCALL COMNWRT        ; Call command write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #85H          ; Set cursor at line 1, position 1\n    LCALL COMNWRT        ; Call command write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #'E'          ; Display letter 'E'\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #'X'          ; Display letter 'X'\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #'P'          ; Display letter 'P'\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #':'          ; Display colon ':'\n    LCALL DATAWRT        ; Call data write subroutine\n    MOV A, #'0'          ; Display number '0'\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #'4'          ; Display number '4'\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n\n    MOV A, #0C3H         ; Set cursor at line 2, position 1\n    LCALL COMNWRT        ; Call command write subroutine\n    LCALL DELAY          ; Give LCD some time\n\n    MOV A, #'8'          ; Display number '8'\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #' '          ; Display space\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #'B'          ; Display letter 'B'\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #'i'          ; Display letter 'i'\n    LCALL DATAWRT        ; Call data write subroutine\n    MOV A, #'t'          ; Display letter 't'\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #' '          ; Display space\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #'L'          ; Display letter 'L'\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #'C'          ; Display letter 'C'\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n    MOV A, #'D'          ; Display letter 'D'\n    LCALL DATAWRT        ; Call data write subroutine\n    LCALL DELAY          ; Give LCD some time\n    SJMP $               ; Infinite loop\n\n; -----------------------------\n; Command Write Subroutine\n; -----------------------------\nCOMNWRT:\n    LCALL READY          ; Prepare for sending command to LCD\n    MOV P1, A            ; Copy content of register A to port 1\n    CLR P3.4             ; Set RS = 0 for command mode\n    CLR P3.5             ; Set R/W = 0 for write mode\n    SETB P3.6            ; Set E high for pulse\n    ACALL DELAY          ; Give LCD some time\n    CLR P3.6             ; Set E low for H-to-L pulse\n    RET\n\n; -----------------------------\n; Data Write Subroutine\n; -----------------------------\nDATAWRT:\n    LCALL READY          ; Prepare for writing data to LCD\n    MOV P1, A            ; Copy content of register A to port 1\n    SETB P3.4            ; Set RS = 1 for data mode\n    CLR P3.5             ; Set R/W = 0 for write mode\n    SETB P3.6            ; Set E high for pulse\n    ACALL DELAY          ; Give LCD some time\n    CLR P3.6             ; Set E low for H-to-L pulse\n    RET\n\n; -----------------------------\n; Ready Check Subroutine\n; -----------------------------\nREADY:\n    SETB P1.7            ; Set P1.7 to indicate readiness\n    CLR P3.4             ; Clear RS\n    SETB P3.5            ; Set R/W = 1 for read mode\n\nWAIT:\n    CLR P3.6             ; Clear E\n    ACALL DELAY          ; Wait for delay\n    SETB P3.6            ; Set E high\n    JB P1.7, WAIT        ; Wait until P1.7 is high (LCD ready)\n    RET\n\n; -----------------------------\n; Delay Subroutine\n; -----------------------------\nDELAY:\n    MOV R3, #50          ; Set outer loop count (50 or higher for fast CPUs)\nHERE2:\n    MOV R4, #255         ; Set inner loop count (255)\nHERE:\n    DJNZ R4, HERE        ; Decrement R4 and repeat until it reaches 0\n    DJNZ R3, HERE2       ; Decrement R3 and repeat until it reaches 0\n    RET\n\nEND                     ; End of program\n\n```\n\n### Code Explanation\n\n- **LCD Initialization**: The `LCD_INIT` procedure sets the LCD in 8-bit mode, turns on the display, and clears it.\n- **Command and Data Functions**: `LCD_CMD` sends commands to the LCD, while `LCD_DATA` sends data (characters).\n- **String Sending**: The `SEND_STRING` procedure sends a null-terminated string to the LCD for display.\n- **Main Program**: The `MAIN` procedure initializes the LCD and sends the string to display.\n\n### Usage\n\n1. **Save the Code**: Copy this code into a file named `lcd.asm`.\n2. **Compile**: Use a compatible assembler to compile the code.\n3. **Simulate or Upload**: Use Proteus for simulation or upload it to the AT89C51 microcontroller.\n\n\n## 🌐 **LCD Interfacing with 8051 – Working**\n\nUpon powering the circuit, the **AT89C51 microcontroller** initializes the LCD and sends a message to be displayed. This can be tested through simulation or real hardware.\n\n---\n\n\n## 📜 **LCD Commands Table**\n\n\u003cdiv align=\"center\"\u003e\n\n| **Command**                       | **Hex Code** | **Description**                                       |\n|-----------------------------------|--------------|-------------------------------------------------------|\n| **Clear Display**                 | `0x01`      | Clears the LCD and resets the cursor to home position. |\n| **Return Home**                   | `0x02`      | Returns the cursor to the home position.              |\n| **Entry Mode Set**                | `0x04`      | Sets the entry mode; cursor moves to the right.       |\n| **Display ON/OFF Control**        | `0x0C`      | Turns the display on with the cursor off.             |\n| **Cursor ON/OFF Control**         | `0x0E`      | Turns the cursor on, but without blinking.            |\n| **Blinking Cursor ON**            | `0x0F`      | Turns the blinking cursor on.                          |\n| **Shift Display Right**           | `0x1C`      | Shifts the entire display to the right.                |\n| **Shift Display Left**            | `0x18`      | Shifts the entire display to the left.                 |\n| **Function Set**                  | `0x38`      | Sets the interface to 8-bit, 2-line mode with 5x7 dots. |\n| **Set Cursor Position**           | `0x80`      | Sets the cursor position to the specified address.     |\n| **Scroll Display Right**          | `0x1C`      | Scrolls the display right.                             |\n| **Scroll Display Left**           | `0x18`      | Scrolls the display left.                              |\n| **Set CGRAM Address**             | `0x40`      | Sets the address for the character generator RAM.      |\n| **Set DDRAM Address**             | `0x80`      | Sets the address for the display data RAM.             |\n\n\u003c/div\u003e\n\n---\n\n\n\n## 📝 **Tasks**\n\n- Verify the connections based on the schematic.\n- Modify the code to display different messages.\n- Experiment with the contrast and observe its effects.\n\n---\n\n## 🔗 **Resources**\n\n- **8051 Microcontroller Reference**: [Datasheet](https://www.atmel.com/products/microcontrollers/8051.aspx)\n- **LCD Datasheet**: [HD44780 LCD Controller](https://www.sparkfun.com/datasheets/LCD/HD44780.pdf)\n\n---\n\n### 🛠️ **Future Work**\n- Adding more functionalities such as scrolling text, custom characters, and additional interfacing techniques like 4-bit mode.\n---\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/gmostofabd/8051-LCD/blob/82e89081c795286c466389d6ac5c34e6ec4a8050/assets/images/LCD_4B_8051_Ckt.png\" alt=\"4-bit LCD Circuit\" width=\"70%\"\u003e\n\u003c/p\u003e\n```\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmostofabd%2F8051-lcd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmostofabd%2F8051-lcd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmostofabd%2F8051-lcd/lists"}