#include #include #define HD44780_CLEAR 0x01 #define HD44780_HOME 0x02 #define HD44780_ENTRY_MODE 0x04 #define HD44780_EM_SHIFT_CURSOR 0 #define HD44780_EM_SHIFT_DISPLAY 1 #define HD44780_EM_DECREMENT 0 #define HD44780_EM_INCREMENT 2 #define HD44780_DISPLAY_ONOFF 0x08 #define HD44780_DISPLAY_OFF 0 #define HD44780_DISPLAY_ON 4 #define HD44780_CURSOR_OFF 0 #define HD44780_CURSOR_ON 2 #define HD44780_CURSOR_NOBLINK 0 #define HD44780_CURSOR_BLINK 1 #define HD44780_DISPLAY_CURSOR_SHIFT 0x10 #define HD44780_SHIFT_CURSOR 0 #define HD44780_SHIFT_DISPLAY 8 #define HD44780_SHIFT_LEFT 0 #define HD44780_SHIFT_RIGHT 4 #define HD44780_FUNCTION_SET 0x20 #define HD44780_FONT5x7 0 #define HD44780_FONT5x10 4 #define HD44780_ONE_LINE 0 #define HD44780_TWO_LINE 8 #define HD44780_4_BIT 0 #define HD44780_8_BIT 16 #define HD44780_CGRAM_SET 0x40 #define HD44780_DDRAM_SET 0x80 #define PORT(x) XPORT(x) #define XPORT(x) (PORT##x) #define PIN(x) XPIN(x) #define XPIN(x) (PIN##x) #define DDR(x) XDDR(x) #define XDDR(x) (DDR##x) #define LCD_DATA_PORT D #define LCD_RS_PORT D #define LCD_RW_PORT D #define LCD_E_PORT D #define LCD_D4_PIN 4 #define LCD_D5_PIN 5 #define LCD_D6_PIN 6 #define LCD_D7_PIN 7 #define LCD_RS_PIN 1 #define LCD_RW_PIN 2 #define LCD_E_PIN 3 void LCD_init(void); void LCD_clear(void); void LCD_goto(uint8_t x, uint8_t y); void LCD_write_text(char * text); int main(void) { DDRC |= (1<> LCD_D4_PIN) & 0x01) != 0) tmp |= (1 << 0); if(((PIN(LCD_DATA_PORT) >> LCD_D5_PIN) & 0x01) != 0) tmp |= (1 << 1); if(((PIN(LCD_DATA_PORT) >> LCD_D6_PIN) & 0x01) != 0) tmp |= (1 << 2); if(((PIN(LCD_DATA_PORT) >> LCD_D7_PIN) & 0x01) != 0) tmp |= (1 << 3); return tmp; } uint8_t LCD_read(void) { uint8_t tmp = 0; DDR(LCD_DATA_PORT) &= ~((1<> 4); PORT(LCD_E_PORT) &= ~(1<> 4); PORT(LCD_E_PORT) &= ~(1<