#include #include void sleep() { for (int i = 0;i < 6300;i++) asm volatile("nop"); } void LCD_command(unsigned char data) { unsigned char dataBits ; dataBits = PORTD & 0xF0; PORTD = dataBits |((data>>4)&0x0F); lcd_renew(); PORTD = dataBits | (data&0x0F); lcd_renew(); PORTD = dataBits | 0x0F; sleep(); } void LCD_enable() { PORTD |= _BV(5); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); PORTD &= ~_BV(5); } void LCD_Text() { PORTD |= _BV(4); unsigned char data = 'a'; unsigned char dataBits ; dataBits = PORTD & 0xF0; PORTD = dataBits |((data>>4)&0x0F); lcd_renew(); PORTD = dataBits | (data&0x0F); lcd_renew(); PORTD = dataBits | 0x0F; PORTD &= ~_BV(4); sleep(); } void LCD_init() { for (int i= 0;i < 50;i++) sleep(); int init = 0b00000111; PORTD = init; LCD_enable(); sleep(); LCD_enable(); sleep(); LCD_enable(); sleep(); init = 0b00000010; PORTD = init; LCD_enable(); sleep(); PORTD = 0x00; init = 0b00101000; LCD_command(); init = 0b00001110; LCD_command(); init = 0b00000101; LCD_command(); init = 0b00000100; LCD_command(); } void main(void) { DDRD = 0xFF; //Definieren Port D als output LCD_init(); LCD_Text(); //gebe test-zeichen aus }