Skip to content

Instantly share code, notes, and snippets.

@SaheblalBagwan
Created May 4, 2016 14:14
/* Function to send the command to LCD.
As it is 4bit mode, a byte of data is sent in two 4-bit nibbles */
void Lcd_CmdWrite(char cmd)
{
LcdDataBus = (cmd & 0xF0); //Send higher nibble
LcdControlBus &= ~(1<<LCD_RS); // Send LOW pulse on RS pin for selecting Command register
LcdControlBus &= ~(1<<LCD_RW); // Send LOW pulse on RW pin for Write operation
LcdControlBus |= (1<<LCD_EN); // Generate a High-to-low pulse on EN pin
delay(1000);
LcdControlBus &= ~(1<<LCD_EN);
delay(10000);
LcdDataBus = ((cmd<<4) & 0xF0); //Send Lower nibble
LcdControlBus &= ~(1<<LCD_RS); // Send LOW pulse on RS pin for selecting Command register
LcdControlBus &= ~(1<<LCD_RW); // Send LOW pulse on RW pin for Write operation
LcdControlBus |= (1<<LCD_EN); // Generate a High-to-low pulse on EN pin
delay(1000);
LcdControlBus &= ~(1<<LCD_EN);
delay(10000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment