Created
August 24, 2016 06:19
-
-
Save prasant1010/db4ba045ec08b33dbe82c2cbc33c6bba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* new_lcd_hardware.c | |
* | |
* Created: 2/8/2016 2:43:34 PM | |
* Author: keshab | |
*/ | |
#ifndef F_CPU | |
# define F_CPU 1000000UL | |
#endif | |
#include <avr/io.h> | |
#include <util/delay.h> | |
#define LCD_DATA PORTA //LCD data port | |
#define ctrl PORTB | |
#define en PB0 // enable signal | |
#define rw PB1 // read/write signal | |
#define rs PB2 //RESET SIGNAL | |
void LCD_cmd(unsigned char cmd); | |
void init_LCD(void); | |
void LCD_write(unsigned char data); | |
int main(void) | |
{ | |
DDRA=0xff; | |
DDRB=0x07; | |
init_LCD(); // initialization of LCD | |
_delay_ms(50); // delay of 50 mili seconds | |
LCD_write('p'); // function to print string on LCD | |
while(1) | |
{ | |
} | |
} | |
void init_LCD(void) | |
{ | |
LCD_cmd(0x38); // initialization of 16X2 LCD in 8bit mode | |
_delay_ms(1); | |
LCD_cmd(0x01); // clear LCD | |
_delay_ms(1); | |
LCD_cmd(0x0E); // cursor ON | |
_delay_ms(1); | |
LCD_cmd(0x80); // ---8 go to first line and --0 is for 0th position | |
_delay_ms(1); | |
return; | |
} | |
void LCD_cmd(unsigned char cmd) | |
{ | |
LCD_DATA=cmd; | |
ctrl =(0<<rs)|(0<<rw)|(1<<en); | |
_delay_ms(1); | |
ctrl =(0<<rs)|(0<<rw)|(0<<en); | |
_delay_ms(50); | |
return; | |
} | |
void LCD_write(unsigned char data) | |
{ | |
LCD_DATA= data; | |
ctrl = (1<<rs)|(0<<rw)|(1<<en); | |
_delay_ms(1); | |
ctrl = (1<<rs)|(0<<rw)|(0<<en); | |
_delay_ms(50); | |
return ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment