Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include "lcd.h"
  2.  
  3. void delay(int delay_t)
  4. {
  5. int i,j;
  6. for(i=0;i<delay_t;i++)
  7. for(j=0;j<1000;j++);
  8. }
  9.  
  10. void LcdInit(void)
  11. {
  12. P2=P3=0;
  13. LcdWriteCommand(0x38);
  14. LcdWriteCommand(0x0C);
  15. LcdWriteCommand(0x01);
  16. LcdWriteCommand(0x80);
  17. LcdWriteStr("** LCD 16X2 **");
  18.  
  19. }
  20.  
  21. void LcdWrite(char wdata)
  22. {
  23. en_pin = 1;
  24. DATA_PORT = wdata;
  25. en_pin = 0;
  26. delay(1);
  27. }
  28.  
  29. void LcdWriteCommand(unsigned char command)
  30. {
  31. rs_pin = 0;
  32. rw_pin = 0;
  33. LcdWrite(command);
  34.  
  35. }
  36. void LcdWriteData(unsigned char cdata)
  37. {
  38. rs_pin = 1;
  39. rw_pin = 0;
  40. LcdWrite(cdata);
  41. }
  42. void LcdWriteStr(char *str)
  43. {
  44. while(*str != '\0')
  45. LcdWriteData(*str++);
  46. }
  47.  
  48. void LcdClear()
  49. {
  50. LcdWriteCommand(0x01);
  51. }
  52.  
  53. void LcdGotoXy(char x,char y) // y-row
  54. {
  55. if(!y)
  56. LcdWriteCommand((x&0x0F)|0xC0);
  57. else
  58. LcdWriteCommand((x&0x0F)|0x80);
  59. }
  60.  
  61. void LcdPrintMsg(char col,char row,char *line1,char col2,char row2,char *line2)
  62. {
  63.  
  64. LcdGotoXy(col,row);
  65. LcdWriteStr(line1);
  66. LcdGotoXy(col2,row2);
  67. LcdWriteStr(line2);
  68. }
  69. void LcdHome()
  70. {
  71. LcdWriteCommand(0x02);
  72. }
  73.  
  74. void LcdWriteCustomChar(char *c_char);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement