juanmv94 / RaspberryPi-LCD-I2C

This library allows you to use an I2C HD44780 based LCD display in the C programming lenguaje with Raspberry Pi using WiringPi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raspberry Pi LCD I2C

About this library

This library allows you to use an I2C HD44780 based LCD display in the C programming lenguaje with Raspberry Pi using WiringPi.

It's based on the C++ LCD I2C library from Arduino, and their commands are similar.

Getting Started

To make this lib to work, you will need the following:

  • Download and install WiringPi (if you don't have it yet).
  • Enable I2C in raspi-config.
    • Run sudo raspi-config.
    • Use the down arrow to select 5 Interfacing Options.
    • Arrow down to P5 I2C.
    • Select yes when it asks you to enable I2C.
    • Reboot.
  • Connect the LCD screen to the I2C pins (SDA, SCL) and power of Raspberry Pi.
  • Check the address of your LCD screen with i2cdetect -y 0 or i2cdetect -y 1 depending your RPI version (you must install i2cdetect first with sudo apt-get install i2c-tools).

Then you can try to compile and run the example.

Basic commands

Here are some of the most important functions of the library:

  • void LCD_begin(char lcd_addr, char lcd_cols, char lcd_rows, char charsize): You need to call this function first to initialize the library with the I2C address, the number of columns of your display, the number of rows of your display, and the char dot size (LCD_5x10DOTS or LCD_5x8DOTS).
  • void LCD_noBacklight(): disables screen backlight.
  • void LCD_backlight(): enables screen backlight.
  • void LCD_write(char): writes a single character to the screen, and increases the cursor position.
  • void LCD_print(char*): writes a string to the screen, and sets the cursor position to the end of the string
  • void LCD_setCursor(char, char): sets the cursor position to the desired coordinates.
  • void LCD_home(): Next print/write operation will will start from the first position on the LCD display.
  • void LCD_clear(): Remove all the characters currently shown. Next print/write operation will start from the first position on LCD display.
  • void LCD_noDisplay(): Do not show any characters on the LCD display. Backlight state will remain unchanged. Also all characters written on the display will return, when the display in enabled again.
  • void LCD_display(): Show the characters on the LCD display, this is the normal behaviour. This method should only be used after LCD_noDisplay() has been used.
  • void LCD_noBlink(): Do not blink the cursor indicator.
  • void LCD_blink(): Start blinking the cursor indicator.
  • void LCD_noCursor(): Do not show a cursor indicator.
  • void LCD_cursor(): Show a cursor indicator, cursor can blink on not blink. Use the methods LCD_blink() and LCD_noBlink() for changing cursor blink.
  • void LCD_createChar(char, char[]): Use this to upload custom characters. Up to eight characters of 5x8 pixels are supported (numbered 0 to 7). The appearance of each custom character is specified by an array of eight bytes, one for each row. The five least significant bits of each byte determine the pixels in that row.

About

This library allows you to use an I2C HD44780 based LCD display in the C programming lenguaje with Raspberry Pi using WiringPi


Languages

Language:C 99.5%Language:Shell 0.5%