Friday, August 15, 2014

AVR library for HD44780


Creator's site
Library itself.
I will show some code explaining how to work with this library.


Image to the left describes information about the pins. VEE == brightness.

All settings could be changed in
lcd.h and lcd.c, you need to download them and add them to your project (Atmel studio).


Open lcd.h  and configure it as you need.
#define XTAL 4000000     // Frequency of your MC.
#define LCD_IO_MODE 1 //1 for 4 bit mode, 0 for 8 bit mode (i use 4 bit == 4 data wires).
#define LCD_PORT         PORTA     // What port you will use for output.

Now add lcd.h to your code:

#include "lcd.h"

 // бла бла бла

lcd_init(LCD_DISP_ON);            // Turn display ON without coursor
lcd_init(LCD_DISP_ON_CURSOR);     // with cursor
lcd_clrscr();                     // clear display
lcd_home();                       // move cursor to begining (x=0; y=0)
lcd_puts("hello");                // write string
lcd_gotoxy(0,1);                  // move cursor (x=0; y=1)

// write numbers
char buffer[10]; 
int n = 12345; 
itoa(n, buffer, 10);
lcd_puts(buffer);

// float
char buffer[10]; 
float f = 3.1415926; 
sprintf(buffer, "%f", f); 
lcd_puts(buffer);

No comments :

Post a Comment