Skip to content

Instantly share code, notes, and snippets.

@faraazahmad
Created February 27, 2019 06:46
Show Gist options
  • Save faraazahmad/57fb16ee11c1a671ffeadc8f40b2507f to your computer and use it in GitHub Desktop.
Save faraazahmad/57fb16ee11c1a671ffeadc8f40b2507f to your computer and use it in GitHub Desktop.
lcd
#include <LCD.h>
/*
#define display_port P2 //Data pins connected to port 2 on microcontroller
sbit rs = P3^2; //RS pin connected to pin 2 of port 3
sbit rw = P3^3; // RW pin connected to pin 3 of port 3
sbit e = P3^4; //E pin connected to pin 4 of port 3
void msdelay(unsigned int time) // Function for creating delay in milliseconds.
{
unsigned int i,j ;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
void lcd_cmd(unsigned char command) //Function to send command instruction to LCD
{
display_port = command;
rs = 0;
rw = 0;
e = 1;
msdelay(1);
e = 0;
}
void lcd_data(unsigned char disp_data) //Function to send display data to LCD
{
display_port = disp_data;
rs = 1;
rw = 0;
e = 1;
msdelay(1);
e = 0;
}
void lcd_init() //Function to prepare the LCD and get it ready
{
lcd_cmd(0x38); // for using 2 lines and 5X7 matrix of LCD
msdelay(10);
lcd_cmd(0x0F); // turn display ON, cursor blinking
msdelay(10);
lcd_cmd(0x01); //clear screen
msdelay(10);
lcd_cmd(0x81); // bring cursor to position 1 of line 1
msdelay(10);
}
*/
void main()
{
/*
unsigned char a[7] = "FARAAZ"; //string of characters
int l = 0;
lcd_init();
while(a[l] != '\0') // searching the null terminator in the sentence
{
lcd_data(a[l]);
l++;
msdelay(50);
}
*/
LCD_INIT();
LCD_CMD(LCD_CLEAR);
LCD_WRITE("FARAAZ 49", 0, 0);
LCD_WRITE("TANMAY 50", 1, 0);
while (1) { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment