{"id":16635752,"url":"https://github.com/eshansurendra/liquid_crystal_i2c_avr","last_synced_at":"2025-09-02T18:32:49.075Z","repository":{"id":253488600,"uuid":"843663947","full_name":"eshansurendra/liquid_crystal_i2c_avr","owner":"eshansurendra","description":"This repository contains an AVR microcontroller implementation of the Liquid Crystal I2C interface. It allows users to control a 16x2 character LCD display using the I2C protocol, freeing up microcontroller pins and simplifying wiring for embedded projects.","archived":false,"fork":false,"pushed_at":"2024-08-20T15:00:32.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T00:31:04.844Z","etag":null,"topics":["avr-programming","i2c","i2c-display","liquid-crystal"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eshansurendra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-08-17T03:44:32.000Z","updated_at":"2024-08-20T15:00:36.000Z","dependencies_parsed_at":"2024-08-20T17:06:21.720Z","dependency_job_id":null,"html_url":"https://github.com/eshansurendra/liquid_crystal_i2c_avr","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"71cf4de1549e019156bbbdd6553f78ee5d7d6790"},"previous_names":["eshansurendra/liquid_crystal_i2c_avr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eshansurendra/liquid_crystal_i2c_avr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshansurendra%2Fliquid_crystal_i2c_avr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshansurendra%2Fliquid_crystal_i2c_avr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshansurendra%2Fliquid_crystal_i2c_avr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshansurendra%2Fliquid_crystal_i2c_avr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eshansurendra","download_url":"https://codeload.github.com/eshansurendra/liquid_crystal_i2c_avr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshansurendra%2Fliquid_crystal_i2c_avr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267843005,"owners_count":24153135,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["avr-programming","i2c","i2c-display","liquid-crystal"],"created_at":"2024-10-12T06:04:37.585Z","updated_at":"2025-07-30T09:08:12.330Z","avatar_url":"https://github.com/eshansurendra.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AVR microcontroller implementation of the Liquid Crystal I2C interface\nThis repository provides an AVR implementation for interfacing with standard character LCD displays (16x2 or 20x4) using the I2C communication protocol. The code is optimized for AVR microcontrollers, offering a lightweight and efficient way to control LCDs without relying on external libraries like the Arduino framework. By using I2C, you can significantly reduce the number of pins required for communication, simplifying wiring and freeing up valuable microcontroller resources.\n\n### Repository Structure\n\nThe repository is structured as follows:\n\n- **`main.c`**: This file serves as an example application, demonstrating how to use the LCD I2C library to initialize the LCD, send commands, and display text.\n\n### Code Overview\n\n#### TWI (Two-Wire Interface / I2C) Initialization (`TWI_init()`)\n\n```c\nvoid TWI_init(void) {\n    TWSR = 0x00;  // Set prescaler to 1\n    TWBR = 0x48;  // Set bit rate for 100kHz I2C clock\n    TWCR = (1 \u003c\u003c TWEN);  // Enable TWI\n}\n```\n- `TWSR`: The TWI Status Register is configured to set the prescaler for the I2C clock.\n- `TWBR`: The TWI Bit Rate Register determines the I2C clock frequency based on the microcontroller's system clock.\n- `TWCR`: The TWI Control Register enables the Two-Wire Interface.\n\n#### LCD Initialization (`lcd_init()`)\n\n```c\nvoid lcd_init(void) {\n    _delay_ms(50);  // Wait for LCD to power up\n    lcd_command(0x02);  // Initialize LCD in 4-bit mode\n    lcd_command(0x28);  // Function set: 4-bit mode, 2 lines, 5x8 dots\n    lcd_command(0x0C);  // Display on, cursor off\n    lcd_command(0x06);  // Entry mode set: Increment cursor\n    lcd_command(0x01);  // Clear display\n    _delay_ms(2);\n}\n```\n\n- This function initializes the LCD module by sending a series of commands. \n- It configures the LCD for 4-bit mode, sets the number of lines and font size, turns on the display, hides the cursor, and clears any existing characters.\n\n#### Sending Data and Commands\n\nThe `lcd_send()` function handles the transmission of both data and commands to the LCD:\n\n```c\nvoid lcd_send(uint8_t value, uint8_t mode) {\n    TWI_start();  // Start I2C communication\n    TWI_write(LCD_ADDR \u003c\u003c 1);  // Write LCD address\n\n    // Send upper nibble\n    uint8_t data = (value \u0026 0xF0) | mode | 0x08;\n    TWI_write(data);\n    TWI_write(data | 0x04); // Pulse enable bit\n    TWI_write(data \u0026 ~0x04);\n\n    // Send lower nibble\n    data = ((value \u003c\u003c 4) \u0026 0xF0) | mode | 0x08;\n    TWI_write(data);\n    TWI_write(data | 0x04); // Pulse enable bit\n    TWI_write(data \u0026 ~0x04);\n\n    TWI_stop();  // Stop I2C communication\n}\n```\n- `value`: The data or command to be sent.\n- `mode`: Specifies whether the `value` is data (1) or a command (0).\n\n#### Key Functions\n\n- `lcd_command(uint8_t command)`: Sends a command to the LCD module.\n- `lcd_data(uint8_t data)`: Sends a character to be displayed on the LCD.\n- `lcd_set_cursor(uint8_t row, uint8_t col)`: Sets the cursor position on the LCD.\n- `lcd_print(char* str)`: Prints a null-terminated string to the LCD.\n\n#### Connections (ATMega328P Example):\n\n   | I2C LCD | ATMega328P |\n   |---------|-------------|\n   | VCC     | 5V         |\n   | GND     | GND        |\n   | SCL     | SCL or A5   |\n   | SDA     | SDA or A4   |\n\n### Common LCD Operations\n\nHere are examples of common LCD operations using the provided implementation:\n\n**1. Clear the Display**\n\n```c\nlcd_command(0x01); // Send the clear display command (0x01)\n```\n\n**2. Set Cursor Position**\n\nTo set the cursor to a specific row and column:\n\n```c\nlcd_set_cursor(0, 2);  // Set cursor to row 0, column 2\nlcd_set_cursor(1, 5);  // Set cursor to row 1, column 5\n```\n\n**3. Print a String**\n\n```c\nlcd_print(\"Hello World!\"); // Print \"Hello World!\" at the current cursor position\n```\n\n## Contributing\n\nContributions are welcome! \n\n- **Bug Fixes:** If you find any bugs or issues, feel free to create an issue or submit a pull request.\n- **Feature Enhancements:** If you have ideas for new features or improvements, don't hesitate to share them.\n\n## Further Information\n\nFor more detailed information on programming the Arduino Uno with Atmel Studio 7 and implementing the LCD I2C interface, please refer to these articles:\n\n- Programming the Arduino Uno Using Atmel Studio 7: [https://medium.com/@janukaeshan/programming-the-arduino-uno-using-atmel-studio-7-99b0915dec1b](https://medium.com/@janukaeshan/programming-the-arduino-uno-using-atmel-studio-7-99b0915dec1b)\n- AVR Microcontroller Implementation of Liquid Crystal I2C Interface: A Comprehensive Guide: [https://medium.com/@janukaeshan/avr-microcontroller-implementation-of-liquid-crystal-i2c-interface-a-comprehensive-guide-8bc4c0ecc857](https://medium.com/@janukaeshan/avr-microcontroller-implementation-of-liquid-crystal-i2c-interface-a-comprehensive-guide-8bc4c0ecc857)\n\n# License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feshansurendra%2Fliquid_crystal_i2c_avr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feshansurendra%2Fliquid_crystal_i2c_avr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feshansurendra%2Fliquid_crystal_i2c_avr/lists"}