Jestin_cubetech
Advanced Member level 1
3 Wire serial LCD [ 74HC595 and 20X4 LCD]
Code:
//4bit lcd mode
#define L_SCK RD0 //LATCH CK
#define S_SCK RD1 //SHIFT CK
#define SDO RD2 //DATA OUTPUT
#define LATCH L_SCK=1; L_SCK=0;
#define SHIFT S_SCK=1; S_SCK=0;
void serial_lcd(unsigned char val)
{
for(char i=0;i<8;i++)
{
SDO=(val&0X80)>>7; val<<=1; //LSB lcd control pins and MSB Lcd data pins
SHIFT;
}
LATCH;
}
void lcd_send(unsigned char type,unsigned char val) //type 0=command 1=data lcd value
{
serial_lcd(type|(val&0xf0)); //Set RS and Data
serial_lcd(0x04|(val&0xf0)); // EN=1 and Data
serial_lcd(type|(val&0xf0)); //EN=0 and Data
serial_lcd(type|((val<<4)&0xf0)); //Set RS and Data
serial_lcd(0x04|(val<<4)&0xf0); // EN=1 and Data
serial_lcd(type|((val<<4)&0xf0)); //EN=0 and Data
}