Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 16000000UL
- #include "LCD.h"
- #include <avr/io.h>
- #include <util/delay.h>
- void LCD_command(unsigned char command)
- {
- LCD_CONTROL &= ~((1<<EN) | (1<<RS) | (1<<RW));
- _delay_us(1);
- LCD_DATABUS = command;
- LCD_CONTROL |= (1<<EN);
- _delay_us(1);
- LCD_CONTROL &= ~(1<<EN);
- _delay_us(40);
- }
- void LCD_data(unsigned char data)
- {
- LCD_CONTROL &= ~((1<<EN) | (1<<RW));
- LCD_CONTROL |= (1<<RS);
- _delay_us(1);
- LCD_DATABUS = data;
- LCD_CONTROL |= (1<<EN);
- _delay_us(1);
- LCD_CONTROL &= ~(1<<EN);
- _delay_us(40);
- }
- void LCD_string(unsigned char command, char* string)
- {
- LCD_command(command);
- while(*string != '\0')
- {
- LCD_data(*string);
- string++;
- }
- }
- void LCD_init()
- {
- LCD_DATABUS_DDR = 0b11111111;
- LCD_CONTROL_DDR |= ((1<<EN) | (1<<RS) | (1<<RW));
- _delay_us(50);
- LCD_CONTROL |= ((1<<EN) | (1<<RS));
- _delay_us(50);
- LCD_CONTROL &= ~(1<<EN);
- _delay_us(50);
- LCD_command(0x38);
- LCD_command(0x0C);
- LCD_command(0x06);
- LCD_command(0x01);
- _delay_ms(10);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement