Microcontroller › AVR › How to Interface 4-bit & 8-bit Lcd Step by Step
- This topic has 2 replies, 3 voices, and was last updated 6 years, 7 months ago by Ashutosh Bhatt.
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
July 28, 2017 at 6:08 pm #4682FarooghParticipant
Hi Every one Please tell me How to interface 4-bit Lcd Step by Step
this My Code for Lcd Initialization
Create a Heade File and past the code in it it Will Work
**************************************************************************************************************************************************
#ifndef LCD_H#define LCD_H#include <avr/io.h>#define F_CPU 1000000UL#include <util/delay.h>char colmn[2]={0x80,0xC0};#define LcdData PORTB#define LcdDataDDR DDRB#define LcdCtrlDDR DDRD#define LcdCtrl PORTD#define RS PD0#define RW PD1#define E PD2void Lcd_Ini(void);void SendData(unsigned char data);void LcdString(char *str);void SendCmd(unsigned char cmd);void SetCursor(uint8_t x,uint8_t y);void Lcd_Ini(){SendCmd(0x38);_delay_us(50);SendCmd(0x01);_delay_ms(1);SendCmd(0x0E);_delay_us(50);SendCmd(0x80);_delay_us(50);}void SendData(unsigned char data){LcdData = data;LcdCtrl = (1<<RS)|(0<<RW)|(1<<E);_delay_us(50);LcdCtrl = (1<<RS)|(0<<RW)|(0<<E);return;}void SendCmd(unsigned char cmd){LcdData = cmd;LcdCtrl = (0<<RS)|(0<<RW)|(1<<E);_delay_us(1);LcdCtrl = (0<<RS)|(0<<RW)|(0<<E);_delay_ms(1);return;}void LcdString(char *str){int i=0;while(str!='