Venkadesh_M
Advanced Member level 4
- Joined
- Jun 26, 2013
- Messages
- 1,374
- Helped
- 258
- Reputation
- 516
- Reaction score
- 254
- Trophy points
- 1,363
- Location
- Coimbatore, India
- Activity points
- 8,020
0x3
0x3
0x3
0x28 //for 4 bit mode
0x08
0x38
0x01 // clear display
// LCD module connections
sbit LCD_RS at RB5_bit;
sbit LCD_EN at RB7_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;
sbit LCD_RS_Direction at TRISB5_bit;
sbit LCD_EN_Direction at TRISB7_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
// End LCD module connections
void main()
{
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,"Hello World");//Write text'Hello World' in first row
}
#include <pic.h>
#include <htc.h>
#define _XTAL_FREQ 20000000
#define RW RD2
#define RS RD3
#define EN RD1
#define databits PORTD
void delay_ms(void)
{
__delay_ms(31);
__delay_ms(31);
__delay_ms(31);
}
void data(unsigned char c)
{
delay_ms();
databits = ( c & 0xF0 ) | 0x08 | 0x02;
delay_ms();
databits = ( c & 0XF0 ) | 0x08;
delay_ms();
databits = ( ( c << 4 ) & 0xF0 ) | 0x08 | 0x02;
delay_ms();
databits = ( ( c << 4 ) & 0XF0 ) | 0x08;
delay_ms();
}
void cmd(unsigned char c)
{
delay_ms();
databits = ( c & 0xF0 ) | 0x02;
delay_ms();
databits = ( c & 0XF0 );
delay_ms();
databits = ( ( c << 4 ) & 0xF0 ) | 0x02;
delay_ms();
databits = ( ( c << 4 ) & 0XF0 );
delay_ms();
}
main()
{
TRISD = 0;
TRISC = 0;
delay_ms();
delay_ms();
delay_ms();
delay_ms();
cmd(0x33);
delay_ms();
cmd(0x32);
delay_ms();
cmd(0x28);
delay_ms();
cmd(0x08);
delay_ms();
cmd(0x01);
delay_ms();
cmd(0x06);
RC1 = 1;
delay_ms();
data('V');
delay_ms();
data('E');
delay_ms();
data('N');
delay_ms();
data('K');
delay_ms();
data('A');
delay_ms();
data('D');
delay_ms();
data('E');
delay_ms();
data('S');
delay_ms();
data('H');
RC0 = 1;
}
#include <pic.h>
#include <htc.h>
#define _XTAL_FREQ 20000000
#define RW RD2
#define RS RD3
#define EN RD1
#define databits PORTD
void data(unsigned char c)
{
databits = ( c & 0xF0 ) | 0x08 | 0x02;
__delay_us(50);
databits = ( c & 0XF0 ) | 0x08;
__delay_us(50);
databits = ( ( c << 4 ) & 0xF0 ) | 0x08 | 0x02;
__delay_us(50);
databits = ( ( c << 4 ) & 0XF0 ) | 0x08;
}
void cmd(unsigned char c)
{
databits = ( c & 0xF0 ) | 0x02;
__delay_us(50);
databits = ( c & 0XF0 );
__delay_us(50);
databits = ( ( c << 4 ) & 0xF0 ) | 0x02;
__delay_us(50);
databits = ( ( c << 4 ) & 0XF0 );
}
void init(unsigned char c)
{
databits = ( c & 0xF0 ) | 0x02;
__delay_us(50);
databits = ( c & 0XF0 );
__delay_ms(10);
databits = ( ( c << 4 ) & 0xF0 ) | 0x02;
__delay_us(50);
databits = ( ( c << 4 ) & 0XF0 );
}
void puts(char* str)
{
cmd(0x01);
cmd(0x80);
__delay_ms(31);
for(char i = 0; str[i] != 0; i++)
{
__delay_us(20);
data(str[i]);
}
}
void lcd_init(void)
{
__delay_ms(16);
init(0x33);
__delay_ms(1);
cmd(0x32);
__delay_us(20);
cmd(0x2C);
__delay_us(20);
cmd(0x0C);
__delay_us(20);
cmd(0x06);
__delay_us(20);
cmd(0x0C);
__delay_us(20);
cmd(0x01);
__delay_us(20);
cmd(0x80);
__delay_us(20);
}
main()
{
char i, wel[]=" WELCOME";
TRISD = 0;
TRISC = 0;
RC0 = RC1 = RC2 = 0;
lcd_init();
puts(wel);
for( i = 0; i < 50; i++)
__delay_ms(30);
while(1);
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?