Wednesday, August 24, 2016

Library code for interfacing LCD modules with AVR microcontrollers - ATmega328P

A library for LCD modules with the following features:
- Supports 16x1, 16x2, 16x4, 20x4, 20x2, 32x2, 40x2 LCD display modules
- Option for automatically wrapping the text to a new line
- Display of floating numbers
- Numbers can be padded with zeros to maintain user interface layout
- Scrolling a string of characters
- Includes two types of big digits numerical fonts for making a clock
- Has support for user defined fonts and other special fonts included on the HD44780 characters memory
- It does not use external libraries to convert integers to strings thus reducing code size
- Support for 8 and 4 bit mode interface
- LCD backlight dimming or on/off control using PWM
 
You can disable features that you doesn't use to reduce code size.
 

Hardware interfacing ATmega328 AVR microcontroller with a 16x2 LCD module with PWM brightness control

This LCD modules can be connected in 4 bit mode or 8 bit mode. Using 4 bit mode is recommended because it uses less pins but the code is a bit more complex. In the following example I use 4 bit mode.

Hardware interfacing AVR ATmega328 with an 16x2 LCD module with PWM brightness control