AVR2012.02.11 14:29

 

#include <lcd.h> 헤더 안에 있는 함수입니다.

 

void _lcd_ready(void);

void _lcd_write_data(unsigned char data);

 

// write a byte to the LCD character generator or display RAM
void lcd_write_byte(unsigned char addr, unsigned char data);

 

// read a byte from the LCD character generator or display RAM
unsigned char lcd_read_byte(unsigned char addr);

 

// set the LCD display position  x=0..39 y=0..3
void lcd_gotoxy(unsigned char x, unsigned char y);

 

// clear the LCD
void lcd_clear(void);

void lcd_putchar(char c);

 

// write the string str located in SRAM to the LCD
void lcd_puts(char *str);

 

// write the string str located in FLASH to the LCD
void lcd_putsf(char flash *str);

 

// initialize the LCD controller
unsigned char lcd_init(unsigned char lcd_columns);

 

//--------------------------------------------------------------

#include <mega128.h>
#asm
   .equ __lcd_port=0x1B ;PORTA
#endasm
#include <lcd.h>

 

 

void main(void){
  lcd_init(16);

  while(1){
      lcd_gotoxy(0,0);
      lcd_putsf("HELLO");
      
      lcd_gotoxy(0,1);
      lcd_puts("Lcd Test Program");
  };
}

 

 

 

 

4x24 CLCD경우에는

위처럼 선을 연결 하고서

 

#include <mega128.h>
#include <delay.h>

#asm
   .equ __lcd_port=0x1B ;PORTA
#endasm
#include <lcd4x40.h>

 

void main(void){
  lcd_init();

  while(1){

      lcd_clear();
      lcd_gotoxy(0,0);
      lcd_puts("Lcd Test 1-Line");
      lcd_gotoxy(0,1);
      lcd_puts("Lcd Test 2-Line");
      lcd_gotoxy(0,2);
      lcd_puts("Lcd Test 3-Line");
      lcd_gotoxy(0,3);
      lcd_puts("Lcd Test 4-Line");

      delay_ms(1000);
  };
}

 

위처럼 하면 될 것 같습니다.

잘 안되면 lcd4x40.h 내용을 읽어보세요

Posted by 콩알은