iVenki
Member level 3
I can't write into the lcd 16 x 2
This is the code
// Program to display a single alphabet ‘A’ on LCD
/*
LCD data transfer through 8 bit mode
Writing a single letter A on LCD
LCD DATA port----PORT A
ctrl port------PORT B
rs-------PB0
rw-------PB1
en-------PB2
*/
#include<avr/io.h>
#include<util/delay.h>
#define LCD_DATA PORTA // LCD data port
#define ctrl PORTB
#define en PB2 // enable signal
#define rw PB1 // read/write signal
#define rs PB0 // register select signal
void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);
int main()
{
DDRA=0xff; // making LCD_DATA port as output port
DDRB=0x07; // making signal as out put
init_LCD(); // initialization of LCD
_delay_ms(50); // delay of 50 milli seconds
LCD_write('A'); // call a function to write A on LCD
return 0;
}
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); // RS and RW as LOW and EN as HIGH
_delay_ms(1);
ctrl =(0<<rs)|(0<<rw)|(0<<en); // RS, RW , LOW and EN as LOW
_delay_ms(50);
return;
}
void LCD_write(unsigned char data)
{
LCD_DATA= data;
ctrl = (1<<rs)|(0<<rw)|(1<<en); // RW as LOW and RS, EN as HIGH
_delay_ms(1);
ctrl = (1<<rs)|(0<<rw)|(0<<en); // EN and RW as LOW and RS HIGH
_delay_ms(50); // delay to get things executed
return ;
}
Here's the circuit diagram.
**broken link removed**
I want to check if my lcd can write the data or not. How should I do that?
---------- Post added at 16:49 ---------- Previous post was at 16:48 ----------
The problem is I don't get any output in the lcd screen. It's just blank
This is the code
// Program to display a single alphabet ‘A’ on LCD
/*
LCD data transfer through 8 bit mode
Writing a single letter A on LCD
LCD DATA port----PORT A
ctrl port------PORT B
rs-------PB0
rw-------PB1
en-------PB2
*/
#include<avr/io.h>
#include<util/delay.h>
#define LCD_DATA PORTA // LCD data port
#define ctrl PORTB
#define en PB2 // enable signal
#define rw PB1 // read/write signal
#define rs PB0 // register select signal
void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);
int main()
{
DDRA=0xff; // making LCD_DATA port as output port
DDRB=0x07; // making signal as out put
init_LCD(); // initialization of LCD
_delay_ms(50); // delay of 50 milli seconds
LCD_write('A'); // call a function to write A on LCD
return 0;
}
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); // RS and RW as LOW and EN as HIGH
_delay_ms(1);
ctrl =(0<<rs)|(0<<rw)|(0<<en); // RS, RW , LOW and EN as LOW
_delay_ms(50);
return;
}
void LCD_write(unsigned char data)
{
LCD_DATA= data;
ctrl = (1<<rs)|(0<<rw)|(1<<en); // RW as LOW and RS, EN as HIGH
_delay_ms(1);
ctrl = (1<<rs)|(0<<rw)|(0<<en); // EN and RW as LOW and RS HIGH
_delay_ms(50); // delay to get things executed
return ;
}
Here's the circuit diagram.
**broken link removed**
I want to check if my lcd can write the data or not. How should I do that?
---------- Post added at 16:49 ---------- Previous post was at 16:48 ----------
The problem is I don't get any output in the lcd screen. It's just blank